Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Zozi96/hash-forge/llms.txt
Use this file to discover all available pages before exploring further.
Argon2Hasher is a memory-hard password hasher that won the Password Hashing Competition (PHC). It provides tunable resistance against both CPU-based and GPU-based brute-force attacks through three orthogonal cost parameters: time cost (iterations), memory cost, and parallelism. The implementation delegates to argon2-cffi’s PasswordHasher, which produces PHC-formatted strings, and wraps them with a argon2$ prefix for consistency with the rest of the Hash Forge ecosystem.
Installation
Theargon2-cffi package is required. Install it via the argon2 extra:
Import
Argon2Hasher
Constructor
None, the corresponding argon2-cffi default is used. Pass only the parameters you wish to override.
Number of Argon2 iterations. Higher values increase hashing time linearly. Must be at least
2 when provided; raises InvalidHasherError otherwise.Memory usage in kibibytes. Higher values increase memory requirements for an attacker. Must be at least
32768 (32 MiB) when provided; raises InvalidHasherError otherwise.Degree of parallelism (number of threads). Must be at least
1 when provided; raises InvalidHasherError otherwise.Length of the raw hash output in bytes. Must be at least
1 when provided; raises InvalidHasherError otherwise.Length of the random salt in bytes. Must be at least
1 when provided; raises InvalidHasherError otherwise.Hash format
argon2$ prefix is prepended to the standard PHC string produced by argon2-cffi, which encodes the algorithm variant, version, cost parameters, salt, and hash in a single portable string.
Methods
hash(string: str) -> str
Hashes the given password using the configured argon2.PasswordHasher instance. A new random salt is generated on every call.
verify(string: str, hashed_string: str) -> bool
Strips the argon2$ prefix and delegates to argon2.PasswordHasher.verify. Returns False on any verification error, including VerifyMismatchError and InvalidHash.
needs_rehash(hashed_string: str) -> bool
Strips the argon2$ prefix and delegates to argon2.PasswordHasher.check_needs_rehash. Returns True when the hash was produced with different cost parameters than the current PasswordHasher configuration.
