hex

package
v0.0.0-...-68fec7b Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2023 License: MPL-2.0 Imports: 2 Imported by: 0

Documentation

Overview

This packages maps gnablib terms to go (to speed up dev) and adheres to https://datatracker.ietf.org/doc/html/rfc4648#section-8 which says HEX is case-insensitive, but uses upper case letters in all examples no need extra features

Index

Constants

This section is empty.

Variables

View Source
var ErrLength = errors.New("hex string must be composed of pairs of hex values")

Length error (1 extra character.. is it the high or low nibble?)

Functions

func FromBytes

func FromBytes(src []byte) string

Convert a byte array into a hex string, uses uppercase chars

func InvalidHexAt

func InvalidHexAt(b byte, at int) invalidHexAtError

An invalid character(b) found at position(at) in a hex string

func ToBytes

func ToBytes(hex string) ([]byte, error)

Covert a case-insensitive hex string into a byte slice, if any of the hex is malformed (invalid character) or there's an odd number of chars, then an error is returned (and no slice)

func ToBytesFast

func ToBytesFast(hex string) []byte

Convert a case-insensitive hex string into a byte slice, if any of the hex is malformed (invalid character) or there's an odd number of chars, then nil is returned (which may also be a valid answer if len(hex)=0) 3% faster than ToBytes (x64 tests)

Types

This section is empty.

Jump to

Keyboard shortcuts

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