Skip to main content

base64_decode_standard

Function base64_decode_standard 

Source
pub fn base64_decode_standard(text: &str) -> Option<Vec<u8>>
Expand description

What: Decode standard padded base64 (RFC 4648 section 4) into bytes, or nothing when the text is not exactly what base64_standard would print for some bytes. Why: A journal that holds the exact bytes of a name that is not UTF-8 is read back by the wrapper; a text that decodes in more than one way (stray padding, non-zero spare bits) is a damaged record, not a name.

In TS you’d write (pseudocode):

function base64Decode(text: string): Uint8Array | undefined { const bytes = Buffer.from(text, 'base64'); return bytes.toString('base64') === text ? bytes : undefined; }