byteutils

package
v0.0.6-rc1 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddZeroBytesSuffix

func AddZeroBytesSuffix(data []byte, required int) []byte

AddZeroBytesSuffix appends zero bytes such that result byte length == required

func ClearBit added in v1.0.0

func ClearBit(n byte, pos uint) byte

ClearBit clears the bit at pos in n.

func ContainsBytesInSlice

func ContainsBytesInSlice(slice [][]byte, b []byte) bool

ContainsBytesInSlice returns bool if byte slice is contained in input

func IntBytesFromString

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

IntBytesFromString return the integer base 10 string in bytes.

func IsBitSet added in v1.0.0

func IsBitSet(n byte, pos uint) bool

IsBitSet checks if the bit at position is set

func RemoveZeroBytesSuffix

func RemoveZeroBytesSuffix(data []byte) []byte

RemoveZeroBytesSuffix removes zero bytes appended to the end.

func SetBit added in v1.0.0

func SetBit(n byte, pos uint) byte

SetBit sets the bit at pos in the given byte.

func SortByte32Slice added in v1.0.0

func SortByte32Slice(arr [][32]byte) [][32]byte

SortByte32Slice sorts the byte32 slices in ascending order.

Types

type BytesArray added in v1.0.0

type BytesArray [][32]byte

BytesArray is a alias for 32 byte alice

func (BytesArray) Len added in v1.0.0

func (a BytesArray) Len() int

Len returns the length of the slice

func (BytesArray) Less added in v1.0.0

func (a BytesArray) Less(i, j int) bool

Less returns true if i'th item is less than j'th else false

func (BytesArray) Swap added in v1.0.0

func (a BytesArray) Swap(i, j int)

Swap swaps the i, j values with in the array.

type HexBytes added in v1.0.0

type HexBytes []byte

HexBytes is of type bytes with JSON hex string marshaller.

func (HexBytes) Bytes added in v1.0.0

func (h HexBytes) Bytes() []byte

Bytes returns a copy of the HexBytes.

func (HexBytes) MarshalJSON added in v1.0.0

func (h HexBytes) MarshalJSON() ([]byte, error)

MarshalJSON marshall bytes to hex.

func (HexBytes) String added in v1.0.0

func (h HexBytes) String() string

String returns HexBytes in string format.

func (*HexBytes) UnmarshalJSON added in v1.0.0

func (h *HexBytes) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals hex string to bytes.

type OptionalHex added in v1.0.0

type OptionalHex struct {
	HexBytes
}

OptionalHex can have empty hex string and doesn't error.

func (*OptionalHex) UnmarshalJSON added in v1.0.0

func (o *OptionalHex) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshalls hex encoded string to bytes. if the data is an empty string, it decoded value is empty bytes.

Jump to

Keyboard shortcuts

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