hex
Byte/text encodings with typed errors: hexadecimal, and base64/base32 (RFC 4648).
Hex decoding accepts either case and rejects anything that is not pairs of hex digits, so
trim whitespace and strip 0x prefixes before calling it. base64/base32 decoding requires
= padding to a multiple of 4/8 characters and rejects it anywhere but the end.
Install
Section titled “Install”Cargo feature hex (enabled by default). To compile only this module:
or in Cargo.toml:
Import path: helpers4::hex.
| Item | What it does |
|---|---|
base32_decode | Decodes s from base32 (RFC 4648 section 6). |
base32_encode | Encodes data as base32 (RFC 4648 section 6), with = padding. |
base64_decode | Decodes s from base64 (RFC 4648 section 4). |
base64_encode | Encodes data as base64 (RFC 4648 section 4), with = padding. |
decode | Decodes a hexadecimal string (either case) into bytes. |
decode_array | Decodes a hexadecimal string into a fixed-size array, e.g. |
decode_to_slice | Decodes a hexadecimal string into out, which must be exactly half as long as the string. |
encode | Encodes bytes as lowercase hexadecimal. |
encode_upper | Encodes bytes as uppercase hexadecimal. |
Error types
Section titled “Error types”Documented on the page of the helper that returns them.
| Type | Returned by |
|---|---|
Base32DecodeError | base32_decode |
Base64DecodeError | base64_decode |
DecodeError | decode, decode_array, decode_to_slice |
