pub mod bruteforce;
pub mod dictionary;
pub mod pattern;
use openssl::pkcs12::Pkcs12;
use std::sync::{Arc, Mutex};
const CHUNK_SIZE: usize = 16384;
#[inline(always)]
pub(crate) fn check_password(
pkcs12: &Pkcs12,
password: &str,
result: &Arc<Mutex<crate::types::CrackResult>>,
) -> bool {
match pkcs12.parse2(password) {
Ok(_) => {
let mut result_guard = result.lock().unwrap();
result_guard.password = Some(password.to_string());
println!("\nFound correct password: {password}");
true
}
Err(_) => false,
}
}
pub(crate) fn generate_combinations(
charset: &[char],
length: u8,
current: &str,
result: &mut Vec<String>,
) {
if length == 0 {
result.push(current.to_owned());
return;
}
let mut new_str = current.to_owned();
for &c in charset {
new_str.push(c);
generate_combinations(charset, length - 1, &new_str, result);
new_str.pop();
}
}