Documentation ¶
Overview ¶
Package common contains various helper functions.
Index ¶
- Constants
- func Bytes2Hex(d []byte) string
- func CopyBytes(b []byte) (copiedBytes []byte)
- func CreateDirIfNotExist(dir string) error
- func Decrypt(cryptograph string, passphrase string) (string, error)
- func DecryptBytes(encryptedJSON []byte, passphrase []byte) ([]byte, error)
- func Encrypt(raw string, passphrase string) (string, error)
- func EncryptBytes(raw []byte, passphrase []byte) ([]byte, error)
- func FromHex(s string) []byte
- func Hash(size int, data ...[]byte) []byte
- func Hash256(data ...[]byte) []byte
- func Hex2Bytes(str string) []byte
- func Hex2BytesFixed(str string, flen int) []byte
- func Hex32ToBytes(s string) [32]byte
- func Hex64ToBytes(s string) [64]byte
- func HexToBytes(s string) []byte
- func LeftPadBytes(slice []byte, l int) []byte
- func ReverseBytes(str []byte) (result []byte)
- func RightPadBytes(slice []byte, l int) []byte
- func ToHex(b []byte) stringdeprecated
- func ToString(v interface{}) string
- func TrimQuotes(s string) string
Constants ¶
View Source
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 ¶
This section is empty.
Functions ¶
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 Hex2BytesFixed ¶
Hex2BytesFixed returns bytes of a specified fixed length flen.
func Hex32ToBytes ¶
func Hex64ToBytes ¶
func HexToBytes ¶
func LeftPadBytes ¶
LeftPadBytes zero-pads slice to the left up to length l.
func ReverseBytes ¶
func RightPadBytes ¶
RightPadBytes zero-pads slice to the right up to length l.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.