Skip to content

Commit

Permalink
Don't display password
Browse files Browse the repository at this point in the history
  • Loading branch information
Barquadd committed Jan 1, 2023
1 parent 2e87345 commit c5494e6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
9 changes: 2 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8>, n: u32) -> Vec<u8> {
let mut hasher = Sha256::new();
Expand All @@ -21,13 +20,9 @@ fn hash_vec_n_times(v: &Vec<u8>, n: u32) -> Vec<u8> {
}

fn get_user_pass() -> Vec<u8> {
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<u8> = password.as_bytes().to_vec();

let key: Vec<u8> = hash_vec_n_times(&password, 100_000);
key
}
Expand Down

0 comments on commit c5494e6

Please sign in to comment.