diff options
author | Vika <vika@fireburn.ru> | 2023-07-29 21:59:56 +0300 |
---|---|---|
committer | Vika <vika@fireburn.ru> | 2023-07-29 21:59:56 +0300 |
commit | 0617663b249f9ca488e5de652108b17d67fbaf45 (patch) | |
tree | 11564b6c8fa37bf9203a0a4cc1c4e9cc088cb1a5 /kittybox-rs/examples | |
parent | 26c2b79f6a6380ae3224e9309b9f3352f5717bd7 (diff) | |
download | kittybox-0617663b249f9ca488e5de652108b17d67fbaf45.tar.zst |
Moved the entire Kittybox tree into the root
Diffstat (limited to 'kittybox-rs/examples')
-rw-r--r-- | kittybox-rs/examples/password-hasher.rs | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/kittybox-rs/examples/password-hasher.rs b/kittybox-rs/examples/password-hasher.rs deleted file mode 100644 index f11c591..0000000 --- a/kittybox-rs/examples/password-hasher.rs +++ /dev/null @@ -1,33 +0,0 @@ -use std::io::Write; - -use argon2::{Argon2, password_hash::{rand_core::OsRng, PasswordHasher, PasswordHash, PasswordVerifier, SaltString}}; - -fn main() -> std::io::Result<()> { - eprint!("Type a password: "); - std::io::stderr().flush().unwrap(); - let password = { - let mut s = String::new(); - std::io::stdin().read_line(&mut s)?; - - s - }; - - let salt = SaltString::generate(&mut OsRng); - let argon2 = Argon2::default(); - //eprintln!("{}", password.trim()); - let password_hash = argon2.hash_password(password.trim().as_bytes(), &salt) - .expect("Hashing a password should not error out") - .serialize(); - - println!("{}", password_hash.as_str()); - - assert!(Argon2::default() - .verify_password( - password.trim().as_bytes(), - &PasswordHash::new(password_hash.as_str()) - .expect("Password hash should be valid") - ).is_ok() - ); - - Ok(()) -} |