hex

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2020 License: Apache-2.0 Imports: 5 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 Bytes2Hex added in v1.0.5

func Bytes2Hex(bytes []byte) string

Bytes2Hex bytes 2 hex string

func Decode added in v1.1.3

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

Decode decodes a hex string with 0x prefix.

func DecodeBig added in v1.1.3

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 DecodeHex

func DecodeHex(hex string) string

DecodeHex hex decode 2 string

func DecodeUint64 added in v1.1.3

func DecodeUint64(input string) (uint64, error)

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

func Encode added in v1.1.3

func Encode(b []byte) string

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

func EncodeBig added in v1.1.3

func EncodeBig(bigint *big.Int) string

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

func EncodeUint64 added in v1.1.3

func EncodeUint64(i uint64) string

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

func Hex2BigInt

func Hex2BigInt(hex string) (*big.Int, error)

Hex2BigInt hex 2 bigint

func Hex2UInt64 added in v1.0.5

func Hex2UInt64(hex string) (uint64, error)

Hex2UInt64 hex 2 uint64

func MustDecode added in v1.1.3

func MustDecode(input string) []byte

MustDecode decodes a hex string with 0x prefix. It panics for invalid input.

Types

This section is empty.

Jump to

Keyboard shortcuts

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