Skip to main content

decode

Function decode 

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

The bytes of base64 text (standard alphabet, with padding). Line breaks (\n, \r) are skipped, as in encode_lines’s output.

assert_eq!(pltrs_codec::base64::decode("cGx0"), Ok(b"plt".to_vec()));
assert_eq!(pltrs_codec::base64::decode("cG\nw="), Ok(b"pl".to_vec()));
assert!(pltrs_codec::base64::decode("cGw").is_err());

§Errors

When text holds other characters, or is not made of whole groups of four characters with padding only at the end.