Skip to main content

verify_password

Function verify_password 

Source
pub fn verify_password(
    password: &[u8],
    encoded: &str,
    limits: Option<&Params>,
) -> Result<(), Argon2Error>
Expand description

Verify a password against a PHC-encoded hash string.

limits optionally caps the resource usage accepted from the encoded string. The m, t, and p fields of a PHC hash are attacker-controlled whenever the hash is not fully trusted (for example a user-supplied or imported credential), and the decoder would otherwise happily honor a hash requesting gigabytes of memory or billions of passes. When limits is Some, verification fails with Argon2Error::InvalidParams as soon as the decoded parameters exceed any of the given bounds, before any memory is allocated. Pass None when the encoded string is trusted.

See hash_password for an example.