yabase/base32/rfc4648
Values
pub fn decode(
input: String,
) -> Result(BitArray, error.CodecError)
Decode a Base32 string (with or without padding) to a BitArray.
Non-alphabet characters (whitespace, CR/LF, punctuation outside
A-Z, 2-7, and =) are rejected with InvalidCharacter
carrying the offending byte and its position. The alphabet check
runs before the length check so the caller does not see a
misleading InvalidLength when the real fault is an
out-of-alphabet byte.
pub fn decode_strict(
input: String,
) -> Result(BitArray, error.CodecError)
Decode input and additionally reject non-canonical encodings
per RFC 4648 §3.5: the trailing pad bits in a final block of
fewer than 5 bytes must be zero. Useful for signature
verification and content-addressable storage, where the wire
encoding’s uniqueness is part of the contract.
Returns Error(NonCanonical) when the input decodes to bytes
whose canonical re-encoding (uppercase alphabet, padded) differs
from the input. The check is case-insensitive and tolerates
already-padded vs unpadded input — the canonical form is the
uppercase, padded shape produced by encode/1. Other failure
modes (InvalidCharacter, InvalidLength) are surfaced
unchanged from decode/1.