Module base64
Base64 encoding and decoding.
base64 provides encoding and decoding for Base64,
a binary-to-text encoding scheme that represents binary data
in a printable ASCII string format.
Base64 is commonly used for encoding binary data in contexts
where only text can be stored or transmitted,
such as email attachments, URLs, and data URIs.
The crate supports multiple Base64 alphabets and configurations,
including standard Base64, URL-safe Base64, and custom alphabets.
The Engine trait provides encoding and decoding with configurable alphabets.
Examples
Basic encoding and decoding:
use ;
let original = b"Hello, world!";
let encoded = STANDARD.encode;
println!; // "SGVsbG8sIHdvcmxkIQ=="
let decoded = STANDARD.decode.unwrap;
assert_eq!;
Using URL-safe encoding for use in URLs:
use ;
let data = b"data with/special+chars";
let encoded = URL_SAFE_NO_PAD.encode;
println!; // Uses - and _ instead of + and /
let decoded = URL_SAFE_NO_PAD.decode.unwrap;
assert_eq!;
Modules
- alphabet Provides [Alphabet] and constants for alphabets commonly used in the wild.
-
display
Enables base64'd output anywhere you might use a
Displayimplementation, like a format string. - engine Provides the [Engine] abstraction and out of the box implementations.
- prelude Preconfigured engines for common use cases.
-
read
Implementations of
io::Readto transparently decode base64. -
write
Implementations of
io::Writeto transparently handle base64.