argon2_hasher
A minimal-surface Python extension that exposes an optimised, memory-hard Argon2id password hasher implemented in Rust
Installation
Quick-start (debug)
pip install maturin # one-time
maturin develop # builds & installs in debug mode
Production wheel (recommended)
# 1. Build an optimised, CPU-tuned wheel…
RUSTFLAGS="-C target-cpu=native" \
maturin build --release --strip
# 2. Install it
pip install target/wheels/argon2_hasher-*.whl
Why two commands?
maturin developis great for dev loops but compiles without optimisations. For benchmarks or production you’ll want the--releasewheel (20-50 × faster).
Usage
from argon2_hasher import Argon2Hasher
plain_pw = "correct horse battery staple"
# ① Hash ----------------------------------------------------------------
phc = Argon2Hasher.hash(plain_pw) # '$argon2id$v=19$m=8192,t=2,p=4$…'
# ② Verify --------------------------------------------------------------
assert Argon2Hasher.verify(phc, plain_pw) # ✅ True
assert not Argon2Hasher.verify(phc, "wrong pass") # ❌ False
That’s it – no knobs exposed to Python; all tuning happens inside the Rust crate.
API
| Function | Signature | Description |
|---|---|---|
Argon2Hasher.hash |
(plain: str, salt: str | None = None) -> str |
Returns a PHC-encoded Argon2id hash. If salt is None, a cryptographically-secure 16-byte salt is generated. |
Argon2Hasher.verify |
(hash: str, plain: str) -> bool |
Constant-time verification. Returns True if plain matches hash. |
All errors are raised as ValueError (malformed hash / salt) or
RuntimeError (internal hashing error).
Tests
# tests/test_argon2_hasher.py
from argon2_hasher import Argon2Hasher
def test_match():
pw = "my_secure_password"
phc = Argon2Hasher.hash(pw)
assert Argon2Hasher.verify(phc, pw)
def test_mismatch():
phc = Argon2Hasher.hash("secret")
assert not Argon2Hasher.verify(phc, "bad")
def test_speed():
import time, bcrypt
pw = "pw"
t0 = time.perf_counter()
Argon2Hasher.verify(Argon2Hasher.hash(pw), pw)
argon_time = time.perf_counter() - t0
t0 = time.perf_counter()
bcrypt.checkpw(pw.encode(),
bcrypt.hashpw(pw.encode(),
bcrypt.gensalt(rounds=12)))
bcrypt_time = time.perf_counter() - t0
print(f"argon2 {argon_time:.3f}s / bcrypt {bcrypt_time:.3f}s")
License
argon2_hasher is released under the MIT License. See LICENSE
for the full text.
Metadata
Release files for argon2-hasher 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| argon2_hasher-0.1.3.tar.gz | 17.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| argon2_hasher-0.1.3-cp311-cp311-manylinux_2_28_aarch64.whl | CPython 3.11 | CPython 3.11 | Linux glibc 2.28+ ARM64 | Details |
Total release size: 266.9 kB
Release files / argon2_hasher-0.1.3.tar.gz
| Download URL | argon2_hasher-0.1.3.tar.gz |
|---|---|
| Size | 17.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ea11bbfcda5c32ed5030cb4d8d9ca7f7ac8e0aa07c2698cf15c2a167a3ad88b4
|
|
BLAKE2b-256 checksum How to use checksums |
1c80ff432cbadda070a4b0c0d1a754313613465be23ffddc9090cfbdb89bc4d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.8.7
|
Release files / argon2_hasher-0.1.3-cp311-cp311-manylinux_2_28_aarch64.whl
| Download URL | argon2_hasher-0.1.3-cp311-cp311-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 249.5 kB |
| Tags | CPython 3.11 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
8ab820cad397b3ace786efd8fe6fd6a95b6e2a6590808c9137a50cf02af69d40
|
|
BLAKE2b-256 checksum How to use checksums |
36a04aae32aeb35348fcf853bc3cc41bd35e010a9200e2cb889571893e9a62fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.8.7
|
Security for argon2-hasher 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.