hexutil

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyString   = &decError{"empty hex string"}
	ErrSyntax        = &decError{"invalid hex string"}
	ErrMissingPrefix = &decError{"hex string without 0x prefix"}
	ErrOddLength     = &decError{"hex string of odd length"}
	ErrEmptyNumber   = &decError{"hex string \"0x\""}
	ErrLeadingZero   = &decError{"hex number with leading zero digits"}
	ErrUint64Range   = &decError{"hex number > 64 bits"}
	ErrUintRange     = &decError{fmt.Sprintf("hex number > %d bits", uintBits)}
	ErrBig256Range   = &decError{"hex number > 256 bits"}
)

Errors

Functions

func Decode

func Decode(input string) ([]byte, error)

Decode decodes a hex string with 0x prefix.

func DecodeBig

func DecodeBig(input string) (*big.Int, error)

DecodeBig decodes a hex string with 0x prefix as a quantity. Numbers larger than 256 bits are not accepted.

func DecodeBigFromBytesToUint64

func DecodeBigFromBytesToUint64(data []byte) uint64

DecodeBigFromBytesToUint64 decodes a byte array to uint64.

func DecodeNoPrefix

func DecodeNoPrefix(input string) ([]byte, error)

DecodeNoPrefix decodes a hex string without 0x prefix.

func DecodeUint64

func DecodeUint64(input string) (uint64, error)

DecodeUint64 decodes a hex string with 0x prefix as a quantity.

func Encode

func Encode(b []byte) string

Encode encodes b as a hex string with 0x prefix.

func EncodeBig

func EncodeBig(bigint *big.Int) string

EncodeBig encodes bigint as a hex string with 0x prefix. The sign of the integer is ignored.

func EncodeInt64

func EncodeInt64(i int64) string

EncodeInt64 encodes i as a hex string with 0x prefix.

func EncodeNoPrefix

func EncodeNoPrefix(b []byte) string

EncodeNoPrefix encodes b as a hex string without 0x prefix.

func EncodeUint64

func EncodeUint64(i uint64) string

EncodeUint64 encodes i as a hex string with 0x prefix.

func EncodeUint64BytesToHexString

func EncodeUint64BytesToHexString(number []byte) string

EncodeUint64ToBytes encodes a uint64 number to bytes.

func EncodeUint64ToBytes

func EncodeUint64ToBytes(number uint64) []byte

EncodeUint64ToBytes encodes a uint64 number to bytes.

func ExtractHex added in v1.1.5

func ExtractHex(s string) string

ExtractHex hexadecimal value out of a string.

func Has0xPrefix

func Has0xPrefix(input string) bool

Has0xPrefix

Types

This section is empty.

Jump to

Keyboard shortcuts

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