Crates.io | pwned |
lib.rs | pwned |
version | 0.5.0 |
source | src |
created_at | 2018-03-29 20:08:37.72234 |
updated_at | 2021-04-30 18:01:13.549755 |
description | Simple Have I Been Pwned checker |
homepage | |
repository | https://github.com/wisespace-io/pwned-rs |
max_upload_size | |
id | 58113 |
size | 37,711 |
Check your passwords against Have I been pwned?
Add this to your Cargo.toml
[dependencies]
pwned = { git = "https://github.com/wisespace-io/pwned-rs.git" }
It uses the range API, so only the first 5 characters of a SHA1 hashed password are sent to Have I been pwned?
use pwned::api::*;
#[tokio::main]
async fn main() {
let pwned = PwnedBuilder::default()
.build().unwrap();
match pwned.check_password("password").await {
Ok(pwd) => println!("Pwned? {} - Occurrences {}", pwd.found, pwd.count),
Err(e) => println!("Error: {}", e),
}
}
use pwned::api::*;
#[tokio::main]
async fn main() {
let pwned = PwnedBuilder::default()
.user_agent("my_user_agent")
.api_key(std::env::var("HIBP_API_KEY").expect("You need to give your HIBP API key as the HIBP_API_KEY environment variable"))
.build().unwrap();
match pwned.check_email("test@wisespace.io").await {
Ok(answer) => {
for breach in answer {
println!("Service {:?}, breach date {:?} Domain: {:?}", breach.name, breach.breach_date, breach.domain);
}
},
Err(e) => println!("Message: {}", e),
}
}