util

package
v0.0.0-...-bf5c25a Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2020 License: LGPL-3.0-or-later Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesCombine

func BytesCombine(pBytes ...[]byte) []byte

BytesCombine combines some bytes

func Contain

func Contain(target interface{}, obj interface{}) bool

Contain return if the target which is a map or slice contains the obj

func FixBytesLength

func FixBytesLength(bytes []byte, length int) []byte

FixBytesLength fix bytes to bytes which length is length

func GetDataBig

func GetDataBig(data []byte, start *big.Int, size *big.Int) []byte

getDataBig returns a slice from the data based on the start and size and pads up to size with zero's. This function is overflow safe.

func Hex

func Hex(data []byte) string

Hex is the wrapper of fmt.Sprintf("%x", data)

func Hex2Bytes

func Hex2Bytes(str string) []byte

Hex2Bytes returns the bytes represented by the hexadecimal string str. Note: The function is a wrapper of hex.DecodeString, but it ignore the error.

func HexToBytes

func HexToBytes(s string) ([]byte, error)

HexToBytes will remove 0x or 0X of begin ,and then call hex.DecodeString

func LeftPadBytes

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

LeftPadBytes ...

func Log256

func Log256(x *big.Int) int

Log256 call and down round

func RandNum

func RandNum(max int) int

RandNum return int in [0, max)

func ReadBinFile

func ReadBinFile(path string) ([]byte, error)

ReadBinFile read code from bin file

func RightPadBytes

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

RightPadBytes ...

func SubSlice

func SubSlice(data []byte, offset, length uint64) ([]byte, error)

SubSlice returns a subslice from offset of length length and a bool (true iff slice was possible). If the subslice extends past the end of data it returns A COPY of the segment at the end of data padded with zeroes on the right. If offset == len(data) it returns all zeroes. if offset > len(data) it returns a false

func Uint64ToBytes

func Uint64ToBytes(i uint64) []byte

Uint64ToBytes turn int64 to []byte

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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