hex

package
v0.0.0-...-97e54d3 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const BadNibble = ^uint64(0)

Variables

View Source
var (
	ErrSyntax        = &DecError{"invalid hex string"}
	ErrMissingPrefix = &DecError{"hex string without 0x prefix"}
	ErrEmptyNumber   = &DecError{"hex string \"0x\""}
	ErrLeadingZero   = &DecError{"hex number with leading zero digits"}
	ErrUint64Range   = &DecError{"hex number > 64 bits"}
	ErrBig256Range   = &DecError{"hex number > 256 bits"}
)

TODO Remove

Functions

func DecodeHex

func DecodeHex(str string) ([]byte, error)

DecodeHex converts a hex string to a byte array

func DecodeHexToBig

func DecodeHexToBig(hexNum string) *big.Int

DecodeHexToBig converts a hex number to a big.Int value

func DecodeNibble

func DecodeNibble(in byte) uint64

DecodeNibble decodes a byte into a uint64

func DecodeString

func DecodeString(str string) ([]byte, error)

DecodeString returns the byte representation of the hexadecimal string

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 EncodeToHex

func EncodeToHex(str []byte) string

EncodeToHex generates a hex string based on the byte representation, with the '0x' prefix

func EncodeToString

func EncodeToString(str []byte) string

EncodeToString is a wrapper method for hex.EncodeToString

func EncodeUint64

func EncodeUint64(i uint64) string

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

func MustDecodeHex

func MustDecodeHex(str string) []byte

MustDecodeHex type-checks and converts a hex string to a byte array

Types

type DecError

type DecError struct {
	// contains filtered or unexported fields
}

func (DecError) Error

func (err DecError) Error() string

Jump to

Keyboard shortcuts

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