Wado
<!-- Auto-generated by: wado doc -f markdown core:base64 --> <!-- Do not edit this file directly. -->

core:base64

Base64 encoding and decoding (RFC 4648): standard and URL-safe alphabets, configurable padding via Encoding flags, and lenient decoding that accepts either alphabet with or without padding. Entry points accept any AsByteSlice source (ByteList, ByteArray, ByteSlice, or String).

Synopsis

let encoded = encode(&b"Hello, Wado!");
assert encoded == "SGVsbG8sIFdhZG8h";
assert decode(&encoded) matches { Some(round) && encode(&round) == encoded };

Functions

pub fn encode<S: AsByteSlice>(data: &S) -> String

Encodes bytes as standard Base64 (RFC 4648 §4, padded).

pub fn encode_url<S: AsByteSlice>(data: &S) -> String

Encodes bytes as URL-safe Base64 (RFC 4648 §5, no padding). Equivalent to encode_with(data, Encoding::UrlSafe | Encoding::NoPadding).

pub fn encode_with<S: AsByteSlice>(data: &S, encoding: Encoding) -> String

Encodes bytes as Base64 with custom flags.

pub fn decode<S: AsByteSlice>(encoded: &S) -> Option<ByteList>

Decodes Base64 from text or raw bytes (e.g., HTTP body, file content). Accepts both standard (+/) and URL-safe (-_) alphabets, with or without padding. Returns null on invalid input.

Flags

pub flags Encoding

UrlSafe

NoPadding