Function pwchecker_rs::check_for_pwnage[][src]

pub fn check_for_pwnage(pass: &str) -> Result<Passwd, Box<dyn Error>>

check_for_pwnage checks the given password against the haveibeenpwned breach database.

The pwned passwords api uses k-anonymity to protect the privacy of the users of the api. Only a 5 character prefix of the sha-1 hash of the password is sent to the api, all hashes in the database that begin with that prefix are sent back, and in this function are locally checked to see if they match the original full-length sha-1 hash. As of this writing, the smallest number of returned hashes is 381. More info can be found here.

Examples

let res = pwchecker_rs::check_for_pwnage("helloworld")?;

assert!(res.times_pwned > 0);