Documentation ¶
Overview ¶
Package utils are some **utilities** while developing
Index ¶
- Variables
- func AES256GCMDecrypt(raw []byte, password []byte) (decrypted []byte)
- func AES256GCMEncrypt(raw []byte, password []byte) (encrypted []byte)
- func BigIntPlusPlus(bigInt *big.Int) *big.Int
- func Bytes2Hex(b []byte) string
- func Bytes2PublicKey(data []byte) *secp256k1.PublicKey
- func BytesListEquals(p1, p2 [][]byte) bool
- func CombineBytes(b ...[]byte) []byte
- func CutBytes(a []byte, i int, j int) []byte
- func Hex2Bytes(s string) []byte
- func HexRLPDecode(s string, v any) error
- func HexRLPEncode(v any) string
- func InBytesList(li [][]byte, sub []byte) (in bool)
- func InsertBytes(s []byte, k int, vs ...byte) []byte
- func MaxUint64(i, j uint64) uint64
- func MinUint64(i, j uint64) uint64
- func PackUint16BE(n uint16) []byte
- func PackUint16LE(n uint16) []byte
- func PackUint32BE(n uint32) []byte
- func PackUint32LE(n uint32) []byte
- func PackUint64BE(n uint64) []byte
- func PackUint64LE(n uint64) []byte
- func PublicKey2Bytes(publicKey *secp256k1.PublicKey) []byte
- func RandInt16() int16
- func RandInt32() int32
- func RandInt64() int32
- func RandUint16() uint16
- func RandUint32() uint32
- func RandUint64() uint64
- func ReverseBytes(b []byte) []byte
- func Sha3Sum256(b []byte) []byte
- type Locker
Constants ¶
This section is empty.
Variables ¶
JSON acts as a global json module.
Functions ¶
func AES256GCMDecrypt ¶
AES256GCMDecrypt is used for file decrypt.
func AES256GCMEncrypt ¶
AES256GCMEncrypt is used for file encrypt.
func BigIntPlusPlus ¶
BigIntPlusPlus is a helper func to calculate i++ for big int i.
func Bytes2PublicKey ¶
Bytes2PublicKey is a helper func to convert **compressed** raw bytes to public key.
func BytesListEquals ¶
func CombineBytes ¶
CombineBytes is a helper func to combine bytes without separator.
func HexRLPDecode ¶
func HexRLPEncode ¶
func InBytesList ¶
InBytesList is a helper func to check whether the sub bytes in the li list.
func PackUint16BE ¶
PackUint16BE converts int16 to bytes in BigEndian.
func PackUint16LE ¶
PackUint16LE converts int16 to bytes in LittleEndian.
func PackUint32BE ¶
PackUint32BE converts int32 to bytes in BigEndian.
func PackUint32LE ¶
PackUint32LE converts int32 to bytes in LittleEndian.
func PackUint64BE ¶
PackUint64BE converts int64 to bytes in BigEndian.
func PackUint64LE ¶
PackUint64LE converts int64 to bytes in LittleEndian.
func PublicKey2Bytes ¶
PublicKey2Bytes is a helper func to convert public key to the **compressed** raw bytes.
func RandInt16 ¶
func RandInt16() int16
RandInt16 generates a random int16 number (-32768 to 32767).
func RandInt32 ¶
func RandInt32() int32
RandInt32 generates a random int32 number (-2147483648 to 2147483647).
func RandInt64 ¶
func RandInt64() int32
RandInt64 generates a random int64 number (-9223372036854775808 to 9223372036854775807).
func RandUint16 ¶
func RandUint16() uint16
RandUint16 generates a random uint16 number(0 to 65535). Useful when getting a random port number.
func RandUint32 ¶
func RandUint32() uint32
RandUint32 generates a random uint32 number(0 to 4294967295). Useful when getting a random port number.
func RandUint64 ¶
func RandUint64() uint64
RandUint64 generates a random uint64 number(0 to 18446744073709551615).
func ReverseBytes ¶
ReverseBytes converts bytes order between LittleEndian and BigEndian.
func Sha3Sum256 ¶
Sha3Sum256 is a helper func to calc & return the sha3 sum256 []byte hash.