common

package
v6.1.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2019 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package common contains various helper functions.

Index

Constants

View Source
const Sha256Len = 32

Sha256Len sha256 bytes len

Variables

View Source
var ErrNetWorkDealy = errors.New("ErrNetWorkDealy")

ErrNetWorkDealy error

Functions

func CopyBytes

func CopyBytes(b []byte) (copiedBytes []byte)

CopyBytes Returns an exact copy of the provided bytes

func FromHex

func FromHex(s string) ([]byte, error)

FromHex hex -> []byte

func GetNtpTime

func GetNtpTime(host string) (time.Time, error)

GetNtpTime 利用服务器返回的 t2, t3, 和本地的 t1, t4 校准时间 delt = ((t2-t1)+(t3-t4))/2 current = t4 + delt

func GetRandBytes

func GetRandBytes(min, max int) []byte

GetRandBytes 获取随机字节

func GetRandPrintString

func GetRandPrintString(min, max int) string

GetRandPrintString 获取随机可打印字符串

func GetRandString

func GetRandString(length int) string

GetRandString 获取随机字符串

func GetRealTime

func GetRealTime(hosts []string) time.Time

GetRealTime 获取实际时间

func GetRealTimeRetry

func GetRealTimeRetry(hosts []string, retry int) time.Time

GetRealTimeRetry 重试获取实际时间

func HashHex

func HashHex(d []byte) string

HashHex []byte -> hex

func IsHex

func IsHex(str string) bool

IsHex 是否是hex字符串

func MaxInt32

func MaxInt32(left, right int32) int32

MaxInt32 max

func MinInt32

func MinInt32(left, right int32) int32

MinInt32 min

func Rimp160

func Rimp160(b []byte) []byte

Rimp160 Returns hash: RIMP160( SHA256( data ) ) Where possible, using RimpHash() should be a bit faster

func Sha256

func Sha256(b []byte) []byte

Sha256 加密

func Sha2Sum

func Sha2Sum(b []byte) []byte

Sha2Sum Returns hash: SHA256( SHA256( data ) ) Where possible, using ShaHash() should be a bit faster

func Sha3

func Sha3(b []byte) []byte

Sha3 加密

func ToHex

func ToHex(b []byte) string

ToHex []byte -> hex

Types

type Hash

type Hash [Sha256Len]byte

Hash type

func BytesToHash

func BytesToHash(b []byte) Hash

BytesToHash []byte -> hash

func HexToHash

func HexToHash(s string) Hash

HexToHash hex -> hash

func (Hash) Bytes

func (h Hash) Bytes() []byte

Bytes Get the []byte representation of the underlying hash

func (*Hash) SetBytes

func (h *Hash) SetBytes(b []byte)

SetBytes Sets the hash to the value of b. If b is larger than len(h), 'b' will be cropped (from the left).

Directories

Path Synopsis
Package address 计算地址相关的函数
Package address 计算地址相关的函数
Package crypto 加解密、签名接口定义
Package crypto 加解密、签名接口定义
sha3
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202.
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202.
db
Package db 数据库操作底层接口定义以及实现包括:leveldb、 memdb、mvcc、badgerdb、pegasus、ssdb
Package db 数据库操作底层接口定义以及实现包括:leveldb、 memdb、mvcc、badgerdb、pegasus、ssdb
table
Package table 实现一个基于kv的关系型数据库的表格功能
Package table 实现一个基于kv的关系型数据库的表格功能
Package difficulty 难度计算基础函数
Package difficulty 难度计算基础函数
Package ed25519 implements the Ed25519 signature algorithm.
Package ed25519 implements the Ed25519 signature algorithm.
edwards25519
Package edwards25519 implements operations in GF(2**255-19) and on an Edwards curve that is isomorphic to curve25519.
Package edwards25519 implements operations in GF(2**255-19) and on an Edwards curve that is isomorphic to curve25519.
Package limits 实现设置进程打开文件资源数
Package limits 实现设置进程打开文件资源数
log
Package log 日志相关接口以及函数
Package log 日志相关接口以及函数
log15
Package log15 provides an opinionated, simple toolkit for best-practice logging that is both human and machine readable.
Package log15 provides an opinionated, simple toolkit for best-practice logging that is both human and machine readable.
Package merkle 实现默克尔树相关的hash计算
Package merkle 实现默克尔树相关的hash计算
Package pubsub implements a simple multi-topic pub-sub library.
Package pubsub implements a simple multi-topic pub-sub library.
Package version 软件版本号
Package version 软件版本号

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL