Skip to content

Commit

Permalink
misc
Browse files Browse the repository at this point in the history
  • Loading branch information
agourlay committed May 24, 2024
1 parent 12e8a12 commit c72443a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/password_finder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ pub fn password_finder(
let aes_info = validate_zip(file_path, file_number)?;
match &aes_info {
Some(aes_info) => progress_bar.println(format!(
"Archive is encrypted with AES{} - expect a long wait time",
"Archive encrypted with AES{} - expect a long wait time",
aes_info.aes_key_length * 8
)),
None => progress_bar
.println("Archive is encrypted with ZipCrypto - expect a much faster throughput"),
.println("Archive encrypted with ZipCrypto - expect a much faster throughput"),
}

let (send_found_password, receive_found_password): (Sender<String>, Receiver<String>) =
Expand All @@ -63,7 +63,7 @@ pub fn password_finder(
max_password_len,
} => password_generator_count(charset, *min_password_len, *max_password_len),
PasswordFile(password_list_path) => {
let total = password_reader_count(password_list_path.to_path_buf())?;
let total = password_reader_count(password_list_path.clone())?;
progress_bar.println(format!(
"Using passwords dictionary {password_list_path:?} with {total} candidates."
));
Expand Down
2 changes: 1 addition & 1 deletion src/password_worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ pub fn password_checker(
extraction_buffer.reserve(zip.size() as usize);
match zip.read_to_end(&mut extraction_buffer) {
Err(_) => (), // password collision - continue
Ok(_) => {
Ok(_read) => {
// Send password and continue processing while waiting for signal
send_password_found
.send(password)
Expand Down
10 changes: 6 additions & 4 deletions src/zip_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ pub fn validate_zip(file_path: &Path, file_number: usize) -> Result<Option<AesIn
let aes_data = archive.get_aes_verification_key_and_salt(file_number);
let zip_result = archive.by_index(file_number);
match zip_result {
Ok(_) => Err(FinderError::invalid_zip_error(
"the archive is not encrypted".to_string(),
)),
Ok(z) => Err(FinderError::invalid_zip_error(format!(
"the selected file in the archive is not encrypted (file_number:{} file_name:{})",
file_number,
z.name()
))),
Err(UnsupportedArchive("Password required to decrypt file")) => {
if let Some(aes_zip_info) = aes_data.expect("Archive validated before-hand") {
let aes_key_length = aes_zip_info.aes_mode.key_length();
Expand All @@ -46,7 +48,7 @@ pub fn validate_zip(file_path: &Path, file_number: usize) -> Result<Option<AesIn
}
}
Err(e) => Err(FinderError::invalid_zip_error(format!(
"Unexpected error {e:?}"
"unexpected error while opening archive: {e:?}"
))),
}
}

0 comments on commit c72443a

Please sign in to comment.