Improve memory efficientcy of decryption

master
Trivernis 5 years ago
parent eb506f5b6a
commit 7ac00d911b

@ -129,19 +129,21 @@ fn decrypt(_opts: &Opts, args: &Decrypt) {
if let Some(dict) = dictionary { if let Some(dict) = dictionary {
let sp = spinner("Reading dictionary..."); let sp = spinner("Reading dictionary...");
let dictionary = fs::read_to_string(dict).expect("Failed to read dictionary file!"); let pw_table: Vec<PassKey>;
let lines = dictionary.par_lines(); {
let dictionary = fs::read_to_string(dict).expect("Failed to read dictionary file!");
let pw_table: Vec<PassKey> = lines let lines = dictionary.par_lines();
.map(|line| { pw_table = lines
let parts: Vec<&str> = line.split("\t").collect::<Vec<&str>>(); .map(|line| {
let pw = parts[0].parse().unwrap(); let parts: Vec<&str> = line.split("\t").collect::<Vec<&str>>();
let key_str: String = parts[1].parse().unwrap(); let pw = parts[0].to_string();
let key = base64::decode(&key_str).unwrap(); let key_str: String = parts[1].to_string();
let key = base64::decode(&key_str).unwrap();
(pw, key)
}) (pw, key)
.collect(); })
.collect();
}
sp.message("Dictionary decrypting file multithreaded".into()); sp.message("Dictionary decrypting file multithreaded".into());
if let Some(dec_data) = decrypt_with_dictionary(&data, pw_table, &data_checksum) { if let Some(dec_data) = decrypt_with_dictionary(&data, pw_table, &data_checksum) {
sp.stop(); sp.stop();

Loading…
Cancel
Save