Documentation ¶
Overview ¶
Package hex is an efficient hexadecimal implementation for Golang.
Index ¶
- func Decode(dst, src []byte) (int, error)
- func DecodeString(s string) ([]byte, error)
- func DecodedLen(n int) int
- func Encode(dst, src []byte) int
- func EncodeToString(src []byte) string
- func EncodeUpper(dst, src []byte) int
- func EncodeUpperToString(src []byte) string
- func EncodedLen(n int) int
- func MustDecodeString(str string) []byte
- func RawEncode(dst, src, alpha []byte) int
- func RawEncodeToString(src, alpha []byte) string
- type InvalidByteError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decode ¶
Decode decodes src into DecodedLen(len(src)) bytes, returning the actual number of bytes written to dst.
If Decode encounters invalid input, it returns an error describing the failure.
func DecodeString ¶
DecodeString returns the bytes represented by the hexadecimal string s.
func DecodedLen ¶
DecodedLen returns the length of a decoding of n source bytes.
func Encode ¶
Encode encodes src into EncodedLen(len(src)) bytes of dst. As a convenience, it returns the number of bytes written to dst, but this value is always EncodedLen(len(src)). Encode implements lowercase hexadecimal encoding.
func EncodeToString ¶
EncodeToString returns the lowercase hexadecimal encoding of src.
func EncodeUpper ¶
EncodeUpper encodes src into EncodedLen(len(src)) bytes of dst. As a convenience, it returns the number of bytes written to dst, but this value is always EncodedLen(len(src)). EncodeUpper implements uppercase hexadecimal encoding.
func EncodeUpperToString ¶
EncodeUpperToString returns the uppercase hexadecimal encoding of src.
func EncodedLen ¶
EncodedLen returns the length of an encoding of n source bytes.
func MustDecodeString ¶
MustDecodeString is like DecodeString but panics if the string cannot be parsed. It simplifies safe initialization of global variables holding binary data.
func RawEncode ¶
RawEncode encodes src into EncodedLen(len(src)) bytes of dst. As a convenience, it returns the number of bytes written to dst, but this value is always EncodedLen(len(src)). RawEncode implements hexadecimal encoding for a given alphabet.
func RawEncodeToString ¶
RawEncodeToString returns the hexadecimal encoding of src for a given alphabet.
Types ¶
type InvalidByteError ¶
type InvalidByteError byte
InvalidByteError values describe errors resulting from an invalid byte in a hex string.
func (InvalidByteError) Error ¶
func (e InvalidByteError) Error() string