md5
A small, dependency-free Rust implementation of the MD5 hash function
Repository Health
Technical Analysis
md5 is a compact, single-file Rust crate implementing the MD5 message-digest algorithm as specified in RFC 1321. It exposes a simple md5::compute(bytes) -> Digest function along with an incremental Context API for hashing data in chunks, and supports no_std environments via a std feature flag.
The crate’s own documentation is explicit that MD5 is cryptographically broken and should only be used for interoperability with legacy protocols or systems that mandate it — not for any new security-sensitive design. It remains widely used for non-cryptographic purposes such as checksums, cache keys, and content fingerprinting where collision resistance isn’t a security requirement.
What You Get
- A single
md5::compute(bytes) -> Digestfunction for one-shot hashing - An incremental
Contexttype for hashing data across multiple chunks/streams - A
Digesttype implementingDebug/LowerHex/Deref<Target = [u8; 16]>for easy formatting and byte access no_stdcompatibility via an optionalstdfeature (enabled by default)- Zero external runtime dependencies
Common Use Cases
- Interoperating with legacy protocols or file formats (e.g. certain checksums, ETags, or hash-based cache keys) that mandate MD5
- Computing non-cryptographic content fingerprints for deduplication or cache invalidation
- Generating checksums for data integrity checks where collision resistance against an adversary isn’t required
- Embedded or
no_stdcontexts needing a minimal-footprint hash function without pulling in a larger crypto crate
Under The Hood
Architecture
The entire implementation lives in a single 446-line src/lib.rs: a Digest([u8; 16]) newtype wraps the raw hash output with Debug/LowerHex/Deref implementations for ergonomic formatting, a Context struct implements the RFC 1321 MD5 compression function incrementally over 64-byte blocks, and the top-level compute() function is a thin convenience wrapper that feeds all input through a single Context and finalizes it.
Tech Stack
Pure Rust with zero runtime dependencies, structured to support both std and no_std builds via a #[cfg_attr(not(feature = "std"), no_std)] attribute and a small compatibility shim (use std as core when the std feature is enabled). A benches/ directory provides Criterion-style benchmarks for measuring hashing throughput.
Code Quality
The crate includes doctest examples embedded directly in the module-level documentation (verified at cargo test time) plus dedicated unit tests exercising the RFC 1321 test vectors and edge cases like empty input and multi-chunk incremental hashing. The single-file structure keeps the implementation easy to audit end-to-end, and the module doc comment prominently and responsibly warns that MD5 is cryptographically broken before showing any usage example.
API Design
The one-shot md5::compute() function requires no setup for the common case, while Context provides the same functionality incrementally for streaming data too large to buffer in memory at once — a minimal two-tier API that mirrors common patterns from other Rust hash crates (like sha2), making it immediately familiar to anyone who has used a hashing crate in Rust before.
Used by 8 apps in this directory
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.
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.
Huly Platform
Project Management · Team Chat · Collaboration
Open-source all-in-one workspace that replaces Linear, Jira, Slack, and Notion for product and engineering teams.
Meilisearch
Search
Lightning-fast hybrid search engine with AI-powered semantic and full-text retrieval for modern applications.
PostgresML
Databases · AI Development
Run ML training and LLM inference natively inside PostgreSQL with GPU acceleration — no data movement required.
PostHog
Analytics · Monitoring · Developer Tools
The all-in-one open source product platform combining analytics, session replay, feature flags, error tracking, AI observability, and a built-in data warehouse in a single self-hostable stack.
RustDesk
Networking
Open-source, self-hosted remote desktop built in Rust — your data, your infrastructure, no third-party cloud.
Stalwart
Collaboration
All-in-one secure mail and collaboration server covering IMAP, JMAP, SMTP, CalDAV, CardDAV, and WebDAV in a single memory-safe Rust binary.