Skip to main content

decode_base64_with_limits

Function decode_base64_with_limits 

Source
pub fn decode_base64_with_limits(
    codec: CodecId,
    text: &str,
    limits: DecodeLimits,
) -> Result<Vec<u8>>
Expand description

Decodes standard base64 text back to bytes, enforcing limits on the raw, whitespace-stripped, and decoded lengths BEFORE any bulk allocation.

The raw input length is checked against DecodeLimits::max_input_bytes first, so a gigabyte of base64 (or whitespace-padded base64) is rejected before strip_ascii_whitespace reserves a buffer for it; the cleaned length and the projected decoded length are checked in turn. Otherwise identical to decode_base64: fails closed on any invalid character, length, or padding.

Shared with sim-codec-bitwise-base64 (see encode_base64).