util

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package common contains various helper functions.

Index

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 Bytes2Hex

func Bytes2Hex(d []byte) string

Bytes2Hex returns the hexadecimal encoding of d.

func CopyBytes

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

CopyBytes returns an exact copy of the provided bytes.

func CreateDirIfNotExist

func CreateDirIfNotExist(dir string) error

CreateDirIfNotExist create given folder

func Decrypt added in v0.0.5

func Decrypt(cryptograph string, passphrase string) (string, error)

func DecryptBytes added in v0.0.5

func DecryptBytes(encryptedJSON []byte, passphrase []byte) ([]byte, error)

DecryptBytes decrypt raw json to raw

func Encrypt added in v0.0.5

func Encrypt(raw string, passphrase string) (string, error)

func EncryptBytes added in v0.0.5

func EncryptBytes(raw []byte, passphrase []byte) ([]byte, error)

EncryptBytes encrypts raw by passphrase to json binary

func FromHex

func FromHex(s string) []byte

FromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x".

func Hash

func Hash(size int, data ...[]byte) []byte

func Hash256

func Hash256(data ...[]byte) []byte

func Hex2Bytes

func Hex2Bytes(str string) []byte

Hex2Bytes returns the bytes represented by the hexadecimal string str.

func Hex2BytesFixed

func Hex2BytesFixed(str string, flen int) []byte

Hex2BytesFixed returns bytes of a specified fixed length flen.

func Hex32ToBytes

func Hex32ToBytes(s string) [32]byte

func Hex64ToBytes

func Hex64ToBytes(s string) [64]byte

func HexToBytes

func HexToBytes(s string) []byte

func LeftPadBytes

func LeftPadBytes(slice []byte, l int) []byte

LeftPadBytes zero-pads slice to the left up to length l.

func ReverseBytes

func ReverseBytes(str []byte) (result []byte)

func RightPadBytes

func RightPadBytes(slice []byte, l int) []byte

RightPadBytes zero-pads slice to the right up to length l.

func ToHex deprecated

func ToHex(b []byte) string

ToHex returns the hex representation of b, prefixed with '0x'. For empty slices, the return value is "0x0".

Deprecated: use hexutil.Encode instead.

func ToString added in v0.0.5

func ToString(v interface{}) string

func TrimQuotes

func TrimQuotes(s string) string

TrimQuotes trim quotes of string if quotes exist

Types

This section is empty.

Directories

Path Synopsis
Package hexutil implements hex encoding with 0x prefix.
Package hexutil implements hex encoding with 0x prefix.

Jump to

Keyboard shortcuts

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