util

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package common contains various helper functions.

Index

Constants

This section is empty.

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 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 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