Documentation ¶
Overview ¶
Package common contains various helper functions.
Index ¶
- Constants
- Variables
- func BE_Bytes2Int(buf []byte) int64
- func BE_BytesToUint16(buf []byte) uint16
- func BE_BytesToUint32(buf []byte) uint32
- func BE_BytesToUint64(buf []byte) uint64
- func BE_Int2Bytes(i int64) []byte
- func BE_Uint16ToBytes(i uint16) []byte
- func BE_Uint32ToBytes(i uint32) []byte
- func BE_Uint64ToBytes(i uint64) []byte
- func BigPow(a, b int64) *big.Int
- func Bool2Bytes(b bool) []byte
- func CopyBytes(b []byte) (copiedBytes []byte)
- func CreateDirIfNotExist(dir string) error
- func Decrypt(cryptoGraph, passphrase string) (string, error)
- func DecryptBytes(encryptedJSON, passphrase []byte) ([]byte, error)
- func Encrypt(raw, passphrase string) (string, error)
- func EncryptBytes(raw, passphrase []byte) ([]byte, error)
- func FromHex(s string) []byte
- func Hex2Bytes(str string) []byte
- func HexToBytes(s string) []byte
- func LE_BytesToInt64(buf []byte) int64
- func LE_BytesToUint16(buf []byte) uint16
- func LE_BytesToUint32(buf []byte) uint32
- func LE_BytesToUint64(buf []byte) uint64
- func LE_EncodeVarInt(val uint64) []byte
- func LE_Int64ToBytes(i int64) []byte
- func LE_Uint16ToBytes(i uint16) []byte
- func LE_Uint32ToBytes(i uint32) []byte
- func LE_Uint64ToBytes(i uint64) []byte
- func LeftPadBytes(slice []byte, l int) []byte
- func Max(x, y uint64) uint64
- func Min(x, y uint64) uint64
- func PaddedBigBytes(bigint *big.Int, n int) []byte
- func RandomFixedBytes(length int) []byte
- func RandomFixedString(length int) string
- func RandomFixedStringWithSeed(length int, seed int64) string
- func ReadBits(bigint *big.Int, buf []byte)
- func ReverseBytes(str []byte) (result []byte)
- func RightPadBytes(slice []byte, l int) []byte
- func SafeAdd(x, y uint64) (uint64, bool)
- func SafeMul(x, y uint64) (uint64, bool)
- func SafeSub(x, y uint64) (uint64, bool)
- func String2Bytes(s string) []byte
- func StringToBigInt(str *string) (*big.Int, error)
- func ToIndentString(v interface{}) string
- func ToString(v interface{}) string
- func TrimBuffToString(bytes []byte) string
- func TrimQuotes(s string) string
- func U256(x *big.Int) *big.Int
- func UInt32Max(x, y uint32) uint32
- func UInt32Min(a, b uint32) uint32
- func VerifyEmailFormat(email string) bool
Constants ¶
const ( // StandardScryptN is the N parameter of Scrypt encryption algorithm, using 256MB // memory and taking approximately 1s CPU time on a modern processor. StandardScryptN = 1 << 18 // StandardScryptP is the P parameter of Scrypt encryption algorithm, using 256MB // memory and taking approximately 1s CPU time on a modern processor. StandardScryptP = 1 )
Variables ¶
Functions ¶
func BE_Bytes2Int ¶ added in v1.2.3
func BE_BytesToUint16 ¶ added in v1.4.0
func BE_BytesToUint32 ¶ added in v1.2.3
func BE_BytesToUint64 ¶ added in v1.2.3
func BE_Int2Bytes ¶ added in v1.2.3
func BE_Uint16ToBytes ¶ added in v1.4.0
func BE_Uint32ToBytes ¶ added in v1.2.3
func BE_Uint64ToBytes ¶ added in v1.2.3
func Bool2Bytes ¶ added in v0.0.9
func CreateDirIfNotExist ¶
CreateDirIfNotExist create given folder
func DecryptBytes ¶ added in v0.0.5
DecryptBytes decrypt raw json to raw
func EncryptBytes ¶ added in v0.0.5
EncryptBytes encrypts raw by passphrase to json binary
func FromHex ¶
FromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x".
func HexToBytes ¶
func LE_BytesToInt64 ¶ added in v1.2.3
func LE_BytesToUint16 ¶ added in v1.4.0
func LE_BytesToUint32 ¶ added in v1.3.0
func LE_BytesToUint64 ¶ added in v1.2.3
func LE_EncodeVarInt ¶ added in v1.3.0
func LE_Int64ToBytes ¶ added in v1.2.3
func LE_Uint16ToBytes ¶ added in v1.4.0
func LE_Uint32ToBytes ¶ added in v1.3.0
func LE_Uint64ToBytes ¶ added in v1.2.3
func LeftPadBytes ¶
LeftPadBytes zero-pads slice to the left up to length l.
func PaddedBigBytes ¶ added in v0.0.9
PaddedBigBytes encodes a big integer as a big-endian byte slice. The length of the slice is at least n bytes.
func RandomFixedBytes ¶ added in v1.4.0
func RandomFixedString ¶ added in v1.1.0
func RandomFixedStringWithSeed ¶ added in v1.4.0
func ReadBits ¶ added in v0.0.9
ReadBits encodes the absolute amount of bigint as big-endian bytes. Callers must ensure that buf has enough space. If buf is too short the result will be incomplete.
func ReverseBytes ¶
func RightPadBytes ¶
RightPadBytes zero-pads slice to the right up to length l.
func String2Bytes ¶ added in v0.0.9
func ToIndentString ¶ added in v1.0.1
func ToIndentString(v interface{}) string
func TrimBuffToString ¶ added in v0.0.9
trim the '\00' byte
func U256 ¶ added in v0.0.9
U256 encodes as a 256 bit two's complement number. This operation is destructive.
func VerifyEmailFormat ¶ added in v1.4.0
Types ¶
This section is empty.