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 57 apps in this directory
agentgateway
AI Development · Developer Tools
An open source AI-native proxy that secures, observes, and governs agent-to-LLM, agent-to-tool, and agent-to-agent communication through MCP, A2A, and unified LLM routing.
AppFlowy
Productivity · Project Management · Collaboration
The open-source AI workspace that puts your data, your rules — with local LLMs, CRDT collaboration, and full self-hosting built in.
Bitwarden Server
Password Manager · Security
Self-hosted, open-source password management backend with zero-knowledge encryption and enterprise-grade identity services
Bramble
Password Manager · Security · Authentication
Local-first, end-to-end encrypted password manager that syncs your vault directly between your own devices over a private peer-to-peer mesh — no server, no account, no cloud in the middle.
Cap
Team Chat · Video Conferencing
Open source Loom alternative with GPU-accelerated recording, instant share links, AI summaries, and full self-hosting via Docker Compose.
cmux
Developer Tools · AI Development
A native, Ghostty-based macOS terminal with vertical tabs, agent-aware notifications, and a scriptable browser built for running many parallel AI coding agent sessions instead of juggling tmux panes.
cocoindex
Data Engineering · AI Development
An incremental data indexing engine that keeps AI agent context perpetually fresh by reprocessing only what changed.
Cog
AI Development · Devops · Developer Tools
An open-source CLI that packages machine learning models into standard, production-ready Docker containers — no Dockerfile wrangling, no CUDA version hell.
CubeSandbox
Developer Tools · Security · AI Agents
Instant, concurrent, hardware-isolated MicroVM sandboxes for AI agents — E2B-API compatible, sub-60ms cold starts, and a built-in zero-trust egress proxy, all self-hostable at scale.