use argon2::{
    Argon2,
    password_hash::{PasswordHasher, SaltString, rand_core::OsRng},
};
use std::env;

fn main() {
    let args: Vec<String> = env::args().collect();

    if args.len() != 2 {
        eprintln!("Usage: {} <password>", args[0]);
        std::process::exit(1);
    }

    let password = &args[1];
    let argon2 = Argon2::default();
    let salt = SaltString::generate(&mut OsRng);

    match argon2.hash_password(password.as_bytes(), &salt) {
        Ok(password_hash) => {
            println!("Argon2 hash for '{}': {}", password, password_hash);
        }
        Err(e) => {
            eprintln!("Error generating hash: {}", e);
            std::process::exit(1);
        }
    }
}
