diff --git a/src/lib/crypt.rs b/src/lib/crypt.rs index 660585f..81427ff 100644 --- a/src/lib/crypt.rs +++ b/src/lib/crypt.rs @@ -7,30 +7,6 @@ use rayon::prelude::*; type DesCfb = Cfb; -pub struct EncryptionKeys { - current: u64, -} - -impl Iterator for EncryptionKeys { - type Item = Vec; - - /// Increases the stored number by one - fn next(&mut self) -> Option { - if self.current < std::u64::MAX { - self.current += 1; - Some(self.current.to_be_bytes().to_vec()) - } else { - None - } - } -} - -impl EncryptionKeys { - pub fn new() -> Self { - Self { current: 0 } - } -} - /// Encrypts data with des pub fn encrypt_data(data: &[u8], key: &[u8]) -> Vec { let iv = rand::thread_rng().gen::<[u8; 8]>(); @@ -67,10 +43,9 @@ pub fn decrypt_with_dictionary( }); if let Some((pw, key)) = pass { println!("Password found: {}", pw); - Some(decrypt_data(data, &key)) - } else { - None + return Some(decrypt_data(data, &key)); } + None } /// Decrypts data by generating all possible keys @@ -88,8 +63,7 @@ pub fn decrypt_brute_brute_force(data: &[u8], checksum: &[u8]) -> Option let key: &[u8] = &num.to_le_bytes(); println!("Key found: {:?}", key); - Some(decrypt_data(data, key)) - } else { - None + return Some(decrypt_data(data, key)); } + None }