pub fn argon2_verify(phc: &str, password: &[u8]) -> Result<bool>Available on (crate features
kdf-hkdf or kdf-argon2) and crate feature kdf-argon2 only.Expand description
Verify password against a PHC-encoded Argon2 hash string.
Returns Ok(true) if the password matches, Ok(false) if it does
not, and Error::Kdf if phc is not a parseable Argon2 PHC
string.
Argon2id’s verification re-derives the hash under the encoded parameters and compares in constant time. The cost is the same as computing a fresh hash with those parameters — usually ~100 ms with the default params.
§Errors
Returns Error::Kdf only when phc fails to parse as a valid
PHC string. A correctly-formatted but wrong-password hash returns
Ok(false).
§Example
use crypt_io::kdf;
let phc = kdf::argon2_hash(b"hunter2")?;
assert!(kdf::argon2_verify(&phc, b"hunter2")?);
assert!(!kdf::argon2_verify(&phc, b"hunter3")?);