Skip to main content

decode

Function decode 

Source
pub fn decode(encoded: &str) -> Result<Vec<u8>>
Expand description

Decodes a base32-encoded string, accepting both upper- and lower-case input.

No padding characters are expected or accepted. Returns an empty Vec when encoded is empty.

§Errors

Returns crate::Error::bad_request if any character falls outside the RFC 4648 base32 alphabet (A–Z, 2–7).

§Examples

use modo::encoding::base32;

assert_eq!(base32::decode("MZXW6YTBOI").unwrap(), b"foobar");
// Decoding is case-insensitive
assert_eq!(base32::decode("mzxw6ytboi").unwrap(), b"foobar");
// Invalid characters yield an error
assert!(base32::decode("MZXW1").is_err());