hex

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: AGPL-3.0, AGPL-3.0-or-later Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Base represents the hexadecimal base, which is 16
	Base = 16

	// BitSize64 64 bits
	BitSize64 = 64
)
View Source
const BadNibble = ^uint64(0)

BadNibble is a nibble that is bad

Variables

This section is empty.

Functions

func DecodeBig

func DecodeBig(hexNum string) *big.Int

DecodeBig converts a hex number to a big.Int value

func DecodeHex

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

DecodeHex converts a hex string to a byte array

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 DecodeUint64

func DecodeUint64(str string) uint64

DecodeUint64 type-checks and converts a hex string to a uint64

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 IsValid

func IsValid(s string) bool

IsValid checks if the provided string is a valid hexadecimal value

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
}

DecError represents an error when decoding a hex value

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