Skip to content

std/encoding/hex

import "github.com/eugenioenko/goalchemy/std/encoding/hex"

Package hex encodes and decodes hexadecimal strings.

var ErrLength = errors.New("encoding/hex: odd length hex string")

ErrLength reports an odd-length input to Decode.

func AppendDecode(dst, src []byte) ([]byte, error)

AppendDecode appends the decoding of src to dst. On error it returns the bytes decoded before the error.

func AppendEncode(dst, src []byte) []byte

AppendEncode appends the hexadecimal encoding of src to dst.

func Decode(dst, src []byte) (int, error)

Decode decodes src into dst and returns the number of bytes written. It accepts upper and lower case digits.

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

DecodeString returns the bytes represented by the hexadecimal string s.

func DecodedLen(x int) int

DecodedLen returns the length of a decoding of x source bytes.

func Encode(dst, src []byte) int

Encode writes the lowercase hexadecimal encoding of src into dst and returns EncodedLen(len(src)).

func EncodeToString(src []byte) string

EncodeToString returns the lowercase hexadecimal encoding of src.

func EncodedLen(n int) int

EncodedLen returns the length of an encoding of n source bytes.

type InvalidByteError byte

InvalidByteError reports a byte that is not a hexadecimal digit.

func (e InvalidByteError) Error() string