argon2
A pure-Rust implementation of the Argon2 password hashing function
Repository Health
Technical Analysis
argon2 is a pure-Rust implementation of Argon2, the memory-hard password hashing function that won the Password Hashing Competition in 2015. It implements all three algorithmic variants — Argon2d (GPU-cracking resistant), Argon2i (side-channel resistant), and Argon2id (the recommended hybrid default) — and integrates with the RustCrypto password-hash crate for PHC string encoding/decoding and trait-based password verification.
The crate is part of the RustCrypto password-hashes workspace, which also houses PBKDF2, scrypt, bcrypt-pbkdf, Balloon hashing, SHA-crypt, and yescrypt implementations sharing a common PasswordVerifier/PasswordHash (PHC string) interface. It supports no_std environments (including without alloc), making it usable in embedded targets as well as standard server-side authentication code.
What You Get
- All three Argon2 variants (Argon2d, Argon2i, and the default Argon2id hybrid)
- Optional integration with the
password-hashcrate for PHC string encoding/parsing and a commonPasswordVerifiertrait shared with pbkdf2, scrypt, and other RustCrypto hashers no_stdsupport, includingalloc-free configurations for embedded/constrained targets- Optional
parallelfeature (viarayon) for multi-threaded hashing and azeroizefeature for secure memory wiping of sensitive buffers - Configurable
Paramsfor memory cost, time cost, and parallelism tuning per OWASP recommendations
Common Use Cases
- Hashing and verifying user passwords for authentication in a Rust web service or CLI tool
- Building a multi-algorithm password verifier that can check hashes produced by Argon2, PBKDF2, or scrypt against a single PHC-format string
- Deriving encryption keys from a low-entropy passphrase (e.g. for at-rest file/database encryption) using Argon2’s memory-hard KDF properties
- Embedded or constrained targets that need password/key hashing without a standard allocator (
no_std, no-allocbuilds)
Under The Hood
Architecture: The crate is organized around algorithm.rs (Argon2 core: block filling, mixing, and the d/i/id variant dispatch), block.rs (the 1KB Argon2 memory block type and operations over it), memory.rs (the working-memory matrix the algorithm iterates over), blake2b_long.rs (the variable-output Blake2b hash used internally by Argon2), params.rs (memory/time/parallelism cost parameters and validation), and error.rs/version.rs; lib.rs ties these into the public Argon2 struct implementing the optional password-hash crate’s PasswordHasher/PasswordVerifier traits. Tech Stack: Rust 2024 edition (MSRV 1.85), no_std-first with alloc as an additive feature; depends on base64ct (constant-time base64 for PHC strings) and blake2 for the internal hash primitive, with optional rayon (parallel feature) and zeroize (secure memory wiping) as opt-in features. Code Quality: Ships an extensive [lints.clippy]/[lints.rust] block enforcing missing_docs, unwrap_used warnings, cast-safety lints, and undocumented-unsafe-block checks — a notably strict lint posture for a security-sensitive crate — plus a tests/ directory with known-answer vectors; CI badges reference a dedicated argon2.yml workflow. API Design: The crate offers both a minimal low-level API (Argon2::new(...).hash_password(...)) and, through the shared password-hash trait objects, a pluggable multi-algorithm verifier pattern (as shown in the repo’s own README) that lets callers check a PHC hash string against Argon2, PBKDF2, or scrypt without knowing in advance which algorithm produced it — a deliberate ergonomic win for migrating between hashing schemes.
Used by 16 apps in this directory
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.
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.
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.
Tabby
AI Code Assistants
Self-hosted AI coding assistant — run GitHub Copilot-grade code completion on your own hardware with no cloud dependency.
tabularis
Databases · Developer Tools
Open-source desktop SQL workspace with built-in PostgreSQL, MySQL, and SQLite drivers, SQL notebooks, a visual query builder, and a built-in MCP server for AI agents like Claude and Cursor.
Temps
Analytics · Devops · Monitoring
A self-hosted Rust PaaS that replaces Vercel, Sentry, PostHog, Pingdom, Resend, and E2B with one binary — plus 440+ CLI operations agents like Claude Code can drive directly.
Vaultwarden
Password Manager · Security
Unofficial Bitwarden-compatible server in Rust — run the full Bitwarden ecosystem on a Raspberry Pi using every official client you already have, without the multi-container overhead.