common

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2020 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64Decode

func Base64Decode(b64 string) ([]byte, error)

Base64Decode decodes a string in base64 with optional padding into an array of bytes.

func Base64ToBytes

func Base64ToBytes(base64String string) ([]byte, error)

Base64ToBytes converts a base64 encoded string into array of bytes

func BytesToBase64

func BytesToBase64(bytesArray []byte) string

BytesToBase64 converts an array of bytes to a base64 encoded string

func BytesToUint16

func BytesToUint16(b []byte) uint16

BytesToUint16 returns a uint16 from a byte array

func BytesToUint32

func BytesToUint32(b []byte) uint32

BytesToUint32 returns a uint32 from a byte array

func EthBytesToUint32

func EthBytesToUint32(b []byte) uint32

EthBytesToUint32 converts bytes as big endian to uint32.

func EthBytesToUint64

func EthBytesToUint64(b []byte) uint64

EthBytesToUint64 converts bytes as big endian to uint64.

func HexDecode

func HexDecode(h string) ([]byte, error)

HexDecode decodes a hex string into an array of bytes.

func HexDecodeInto

func HexDecodeInto(dst []byte, h []byte) error

HexDecodeInto decodes a hex string into an array of bytes (dst), verifying that the decoded array has the same length as dst.

func HexEncode

func HexEncode(bs []byte) string

HexEncode encodes an array of bytes into a string in hex.

func SetBit

func SetBit(bitmap []byte, n uint)

SetBit sets the bit n in the bitmap to 1.

func SetBitBigEndian

func SetBitBigEndian(bitmap []byte, n uint)

SetBitBigEndian sets the bit n in the bitmap to 1, in Big Endian.

func SwapEndianness

func SwapEndianness(b []byte) []byte

SwapEndianness swaps the order of the bytes in the slice.

func TestBit

func TestBit(bitmap []byte, n uint) bool

TestBit tests whether the bit n in bitmap is 1.

func TestBitBigEndian

func TestBitBigEndian(bitmap []byte, n uint) bool

TestBitBigEndian tests whether the bit n in bitmap is 1, in Big Endian.

func Uint16ToBytes

func Uint16ToBytes(u uint16) []byte

Uint16ToBytes returns a byte array from a uint16

func Uint32ToBytes

func Uint32ToBytes(u uint32) []byte

Uint32ToBytes returns a byte array from a uint32

func Uint32ToEthBytes

func Uint32ToEthBytes(u uint32) []byte

Uint32ToEthBytes converts a uint32 to bytes in big endian.

func Uint64ToEthBytes

func Uint64ToEthBytes(u uint64) []byte

Uint64ToEthBytes convets a uint64 to bytes in big endian.

func UnmarshalJSONHexDecode

func UnmarshalJSONHexDecode(bs []byte) ([]byte, error)

UnmarshalJSONHexDecode decodes the JSON Hex string and returns the []byte

func UnmarshalJSONHexDecodeInto

func UnmarshalJSONHexDecodeInto(dst []byte, bs []byte) error

UnmarshalJSONHexDecodeInto decodes the JSON Hex string into bs

Types

type Hex

type Hex []byte

Hex is a byte slice type that can be marshalled and unmarshaled in hex

func (Hex) MarshalText

func (buf Hex) MarshalText() ([]byte, error)

MarshalText encodes buf as hex

func (Hex) String

func (buf Hex) String() string

String encodes buf as hex

func (*Hex) UnmarshalText

func (buf *Hex) UnmarshalText(h []byte) error

UnmarshalText decodes a hex into buf

Jump to

Keyboard shortcuts

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