pub struct Cost {
pub memory_kib: u32,
pub iterations: u32,
pub parallelism: u32,
}Expand description
How much work one password hash costs.
Fields§
§memory_kib: u32Memory used per hash, in kibibytes.
iterations: u32Passes over that memory.
parallelism: u32Lanes hashed in parallel.
Implementations§
Source§impl Cost
impl Cost
Sourcepub const DEFAULT: Cost
pub const DEFAULT: Cost
The default: 19 MiB of memory, two passes, one lane.
This is OWASP’s first recommended argon2id configuration. Memory is the parameter that actually defends against attackers: a GPU or ASIC can pipeline iterations cheaply but has to buy 19 MiB of fast memory per guess, which is what collapses their parallelism advantage. Two passes is the minimum argon2id allows at this memory size, and one lane keeps the cost predictable on a busy web server that is already running one request per core.
On a modern server this lands around 40 ms per hash — slow enough to make offline cracking expensive, fast enough that a login request does not feel it.
Sourcepub const FAST: Cost
pub const FAST: Cost
The cheapest configuration argon2 accepts.
Deliberately far too weak for real passwords. It exists because a test suite that hashes a dozen passwords at the real cost spends its whole runtime inside argon2, and a slow suite is a suite that stops being run. Never use this to store a password.