diff --git a/Cargo.toml b/Cargo.toml index 874a71d..4b33f19 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,7 @@ [workspace] +resolver = "2" + members = [ "core", "cli", diff --git a/cli/src/main.rs b/cli/src/main.rs index 9028345..310f3d4 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -88,7 +88,7 @@ fn run() -> Result<(Option, Direction, f64)> { } else if app.passwordfile().is_some() { let pw_file = app.passwordfile().unwrap(); let p = Path::new(&pw_file); - drop(pw_file); + drop(pw_file.to_string()); let tmp=std::fs::read_to_string(p).unwrap(); Secret::new(tmp) } else { diff --git a/core/Cargo.toml b/core/Cargo.toml index d4a4a67..a300543 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -15,7 +15,7 @@ sha3 = "0.10.1" blake3 = "1.3.1" rand = "0.8.5" thiserror = "1.0.30" -indicatif = "0.17.0-rc.11" +indicatif = "0.17.6" zeroize = "1.3.0" [dev-dependencies] diff --git a/core/src/crypto.rs b/core/src/crypto.rs index 2b8e355..344f0d8 100644 --- a/core/src/crypto.rs +++ b/core/src/crypto.rs @@ -16,6 +16,7 @@ use deoxys::DeoxysII256; use rand::prelude::StdRng; use indicatif::{ProgressBar, ProgressStyle}; + pub fn init_encryption_stream( password: &Secret, header_type: HeaderType, @@ -186,10 +187,12 @@ pub fn encrypt<>( let mut buffer = [0u8; MSGLEN]; let mut total_bytes_read = 0; let pb = ProgressBar::new(filesize as u64); - pb.set_style(ProgressStyle::with_template("{spinner:.green} [{elapsed_precise}] [{wide_bar:.cyan/blue}] {bytes}/{total_bytes} ({eta})") - .unwrap() - .with_key("eta", |state| format!("{:.1}s", state.eta().as_secs_f64())) - .progress_chars("#>-")); + pb.set_style( + ProgressStyle::with_template( + "{spinner:.green} [{wide_bar:.cyan/blue}] {bytes}/{total_bytes} ({eta})", + ) + .unwrap() + .progress_chars("#>-"),); loop { let read_count = input.read(&mut buffer).map_err(|e| CoreErr::IOError(e))?; total_bytes_read += read_count; @@ -240,14 +243,14 @@ pub fn encrypt<>( ui.output(percentage); } + pb.finish(); if bench == BenchMode::WriteToFilesystem { output.flush().map_err(|e| CoreErr::IOError(e))?; } if hash == HashMode::CalculateHash { let hash = hasher.finalize().to_hex().to_string(); - println!("Hash of the encrypted file is: {}", hash,); + println!("Hash Blake3 of the encrypted file is: {}", hash,); } - pb.finish(); Ok(()) } @@ -273,10 +276,13 @@ pub fn decrypt<>( let mut total_bytes_read = 0; let pb = ProgressBar::new(filesize as u64); - pb.set_style(ProgressStyle::with_template("{spinner:.green} [{elapsed_precise}] [{wide_bar:.cyan/blue}] {bytes}/{total_bytes} ({eta})") - .unwrap() - .with_key("eta", |state| format!("{:.1}s", state.eta().as_secs_f64())) - .progress_chars("#>-")); + pb.set_style( + ProgressStyle::with_template( + "{spinner:.green} [{wide_bar:.cyan/blue}] {bytes}/{total_bytes} ({eta})", + ) + .unwrap() + .progress_chars("#>-"), + ); loop { let read_count = input.read(&mut buffer)?; total_bytes_read += read_count; @@ -322,11 +328,12 @@ pub fn decrypt<>( ui.output(percentage); } + pb.finish(); if hash == HashMode::CalculateHash { let hash = hasher.finalize().to_hex().to_string(); - println!("Hash of the encrypted file is: {}. If this doesn't match with the original, something very bad has happened.", hash); + println!("Hash Blake3 of the encrypted file is: {}. If this doesn't match with the original, something very bad has happened.", hash); } - pb.finish(); + Ok(()) }