Skip to main content

decode

Function decode 

Source
pub fn decode(
    data: impl AsRef<[u8]>,
    alphabet: Alphabet,
) -> Result<Vec<u8>, DecodeError>
Available on crate feature alloc only.
Expand description

Decodes a base32 string into bytes.

§Errors

Returns DecodeError if any character is invalid for the chosen Alphabet, the input length is not valid, or padding is incorrect.

§Example

let decoded = base32::decode(b"NBSWY3DP", base32::Alphabet::Rfc4648).unwrap();
assert_eq!(decoded, b"hello");