diff --git a/Cargo.toml b/Cargo.toml index f571801..0f7ec37 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,4 +14,5 @@ strip = true aes-gcm = "0.10.1" clap = {version="4.0.32", features=["cargo"]} rand = "0.8.5" +rpassword = "7.2.0" sha2 = "0.10.6" \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 2c1c1fb..ad21498 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,8 +5,7 @@ use aes_gcm::{ }; use clap::{arg, command, value_parser}; use sha2::{Digest, Sha256}; -use std::io::{stdin, stdout}; -use std::{fs::write, io::Write, path::PathBuf}; +use std::{fs::write, path::PathBuf}; fn hash_vec_n_times(v: &Vec, n: u32) -> Vec { let mut hasher = Sha256::new(); @@ -21,13 +20,9 @@ fn hash_vec_n_times(v: &Vec, n: u32) -> Vec { } fn get_user_pass() -> Vec { - print!("Enter the password: "); - stdout().flush().unwrap(); - let mut password = String::new(); - stdin().read_line(&mut password).unwrap(); + let password = rpassword::prompt_password("Please enter a password: ").unwrap(); let password = password.trim(); let password: Vec = password.as_bytes().to_vec(); - let key: Vec = hash_vec_n_times(&password, 100_000); key }