Skip to main content

decode_into

Function decode_into 

Source
pub fn decode_into(
    output: &mut [u8],
    encoded_data: &[u8],
    alphabet: Alphabet,
) -> Result<(), DecodeError>
Expand description

Decodes a base64 string into an existing buffer.

Dispatches to a SIMD-accelerated implementation (AVX2 or NEON) when the target feature is available.

See decode_into_constant_time for security-sensitive and cryptographic operations.

§Errors

Returns DecodeError if any character is invalid for the chosen Alphabet, if the input length is not valid, if padding is incorrect, or if output.len() is too small to hold the decoded data.

§Example

let mut buf = [0u8; 5];
base64::decode_into(&mut buf, b"aGVsbG8=", base64::Alphabet::Standard).unwrap();
assert_eq!(&buf, b"hello");