utils

package
v0.0.0-...-e87e1d8 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package utils are some **utilities** while developing

Index

Constants

This section is empty.

Variables

JSON acts as a global json module.

Functions

func AES256GCMDecrypt

func AES256GCMDecrypt(raw []byte, password []byte) (decrypted []byte)

AES256GCMDecrypt is used for file decrypt.

func AES256GCMEncrypt

func AES256GCMEncrypt(raw []byte, password []byte) (encrypted []byte)

AES256GCMEncrypt is used for file encrypt.

func BigIntPlusPlus

func BigIntPlusPlus(bigInt *big.Int) *big.Int

BigIntPlusPlus is a helper func to calculate i++ for big int i.

func Bytes2Hex

func Bytes2Hex(b []byte) string

Bytes2Hex is a helper func to convert raw bytes to hex string.

func Bytes2PublicKey

func Bytes2PublicKey(data []byte) *secp256k1.PublicKey

Bytes2PublicKey is a helper func to convert **compressed** raw bytes to public key.

func BytesListEquals

func BytesListEquals(p1, p2 [][]byte) bool

func CombineBytes

func CombineBytes(b ...[]byte) []byte

CombineBytes is a helper func to combine bytes without separator.

func CutBytes

func CutBytes(a []byte, i int, j int) []byte

func Hex2Bytes

func Hex2Bytes(s string) []byte

Hex2Bytes is a helper func to convert hex string to raw bytes.

func HexRLPDecode

func HexRLPDecode(s string, v any) error

func HexRLPEncode

func HexRLPEncode(v any) string

func InBytesList

func InBytesList(li [][]byte, sub []byte) (in bool)

InBytesList is a helper func to check whether the sub bytes in the li list.

func InsertBytes

func InsertBytes(s []byte, k int, vs ...byte) []byte

func MaxUint64

func MaxUint64(i, j uint64) uint64

func MinUint64

func MinUint64(i, j uint64) uint64

func PackUint16BE

func PackUint16BE(n uint16) []byte

PackUint16BE converts int16 to bytes in BigEndian.

func PackUint16LE

func PackUint16LE(n uint16) []byte

PackUint16LE converts int16 to bytes in LittleEndian.

func PackUint32BE

func PackUint32BE(n uint32) []byte

PackUint32BE converts int32 to bytes in BigEndian.

func PackUint32LE

func PackUint32LE(n uint32) []byte

PackUint32LE converts int32 to bytes in LittleEndian.

func PackUint64BE

func PackUint64BE(n uint64) []byte

PackUint64BE converts int64 to bytes in BigEndian.

func PackUint64LE

func PackUint64LE(n uint64) []byte

PackUint64LE converts int64 to bytes in LittleEndian.

func PublicKey2Bytes

func PublicKey2Bytes(publicKey *secp256k1.PublicKey) []byte

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

func ReverseBytes(b []byte) []byte

ReverseBytes converts bytes order between LittleEndian and BigEndian.

func Sha3Sum256

func Sha3Sum256(b []byte) []byte

Sha3Sum256 is a helper func to calc & return the sha3 sum256 []byte hash.

Types

type Locker

type Locker struct {
	// contains filtered or unexported fields
}

func NewLocker

func NewLocker() *Locker

func (*Locker) IsLocked

func (l *Locker) IsLocked() bool

func (*Locker) Lock

func (l *Locker) Lock()

func (*Locker) Unlock

func (l *Locker) Unlock()

Jump to

Keyboard shortcuts

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