Skip to main content

decoded_len

Function decoded_len 

Source
pub fn decoded_len(input: &[u8], padded: bool) -> Result<usize, DecodeError>
Expand description

Returns the exact decoded length implied by input length and padding.

This validates padding placement and impossible lengths, but it does not validate alphabet membership or non-canonical trailing bits.

ยงExamples

use base64_ng::decoded_len;

assert_eq!(decoded_len(b"aGVsbG8=", true).unwrap(), 5);
assert_eq!(decoded_len(b"aGVsbG8", false).unwrap(), 5);