base64
Correct, fast, and configurable base64 encoding and decoding for Rust, with pluggable alphabets and padding.
Repository Health
Technical Analysis
base64 is the de facto standard Rust crate for encoding and decoding base64 data, downloaded well over a billion times from crates.io. It exposes an Engine trait so applications can choose the alphabet (standard, URL-safe, or a fully custom one) and padding behavior (canonical, no-pad, or custom padding modes) that fit their protocol, while keeping a single consistent API surface.
The crate targets both convenience and raw throughput: high-level encode/decode methods allocate a String or Vec<u8> for you, while slice- and Vec-based variants let performance-sensitive code avoid extra allocations entirely. It also ships streaming Read/Write adapters and a Display wrapper, is no_std-compatible, and forbids unsafe code throughout, making it a safe default for any Rust codebase that needs to move binary data through text-only channels.
What You Get
- A pluggable Engine trait with a ready-to-use GeneralPurpose implementation and pre-configured STANDARD, STANDARD_NO_PAD, URL_SAFE, and URL_SAFE_NO_PAD engines
- Multiple encode/decode entry points — allocating (String/Vec<u8>), in-place (append to an existing String/Vec), and zero-allocation slice variants — so you can trade convenience for throughput as needed
- Streaming DecoderReader and EncoderWriter adapters for std::io::Read/Write, plus a Base64Display wrapper for formatting without allocating
- no_std and alloc-only build support via Cargo features, with #![forbid(unsafe_code)] guaranteeing memory safety throughout
Common Use Cases
- Encoding binary payloads (images, keys, tokens) into JSON, XML, or other text-only API responses
- Decoding Basic Auth headers, JWT segments, and other base64-encoded HTTP artifacts
- Embedding binary assets or hashes as base64 strings in config files, URLs, or data URIs
- Streaming large files through base64 encoding/decoding without buffering the whole payload in memory
Under The Hood
Architecture — The crate centers on an Engine trait (src/engine/mod.rs) that separates the public encode/decode API from the low-level byte-shuffling implementation. GeneralPurpose (src/engine/general_purpose/) is the only shipped implementation today, parameterized by an Alphabet (src/alphabet.rs) and a GeneralPurposeConfig controlling padding behavior; pre-built STANDARD, STANDARD_NO_PAD, URL_SAFE, and URL_SAFE_NO_PAD constants cover the common RFC 4648 cases. Encoding and decoding logic live in dedicated src/encode.rs and src/decode.rs modules, with src/read/decoder.rs and src/write/encoder.rs layering std::io::Read/Write adapters on top of the same engine calls, so streaming and in-memory paths share one correctness-critical core.
Tech Stack — Pure Rust with the 2018 edition and an MSRV of 1.48.0, no runtime dependencies; dev-dependencies (criterion, rand, clap, strum, rstest) are test/benchmark-only. Cargo features (std, alloc, default std) gate std::io support and heap allocation independently, allowing no_std embedded builds when only alloc (or neither) is enabled.
Code Quality — The crate enforces #![forbid(unsafe_code)] and #![deny(missing_docs, ...)] at the crate root, and carries a large first-party test suite (85+ #[test] functions across src/engine/tests.rs, src/read/decoder_tests.rs, src/write/encoder_tests.rs, and tests/), plus fuzz targets under fuzz/ (roundtrip, roundtrip_no_pad, decode_random) run via cargo-fuzz. Naming is consistent (encode/encode_string/encode_slice mirrored by decode/decode_vec/decode_slice), and error types (DecodeError, DecodeSliceError, EncodeSliceError) are explicit enums rather than opaque strings.
API Design — The Engine trait plus a prelude module give both an explicit, discoverable API (use base64::{engine::general_purpose::STANDARD, Engine as _}) and a minimal-footprint shortcut (use base64::prelude::*). A documented table in the crate-level docs maps each use case (allocate vs. append vs. write-into-buffer) to the right method, and every documented example is a runnable doctest, which keeps the extensive documentation verified against the actual API on every cargo test run.
Used by 66 apps in this directory
Laminar
AI Development · Monitoring
Open-source observability platform purpose-built for AI agents — trace, evaluate, debug, and monitor at scale with SQL access and real-time replay.
Latitude
AI Agents · Monitoring
Open-source AI agent monitoring that catches what will break next before your users do.
LocalSend
Networking
An open-source, cross-platform AirDrop alternative that sends files and messages device-to-device over your local network with no internet, no account, and no cloud server involved.
Lokus
Knowledge Management · Note Taking
Local-first note-taking with graph view, canvas & AI plugins—your Markdown files, zero telemetry, blazing-fast Rust performance.
Apache Maka
AI Agents · AI Development · Developer Tools
An Apache-incubated agent workspace that treats every model call, tool run, and permission decision as an append-only, replayable event log instead of disposable chat history.
Meilisearch
Search
Lightning-fast hybrid search engine with AI-powered semantic and full-text retrieval for modern applications.
melty
AI Code Assistants · Code Editors · Developer Tools
The AI code editor where every chat message is a git commit you can revert, branch, or squash
mesh-llm
AI Agents · AI Development
Mesh LLM pools GPUs and memory across every machine you own into one OpenAI-compatible API, so agents tap distributed compute instead of a single GPU box or a metered cloud bill.
Mistle
AI Agents · Developer Tools
Self-hostable platform for running autonomous coding agents in isolated, credentialless sandboxes with brokered credentials, reusable snapshots, and event-driven triggers.