From 06ccdb4a7e7b84c084d3abf77c8ebf233e7dfa80 Mon Sep 17 00:00:00 2001 From: David-Tillmann Schaefer Date: Fri, 14 Nov 2025 07:28:56 +0100 Subject: [PATCH] fix: apply cargo fmt --- crates/cli-interface/src/lib.rs | 5 ++++- crates/cracker/src/lib.rs | 17 ++++++----------- crates/engine/src/lib.rs | 2 +- crates/producer/src/default_query.rs | 10 +++++----- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/crates/cli-interface/src/lib.rs b/crates/cli-interface/src/lib.rs index ad679ed..ed975c0 100644 --- a/crates/cli-interface/src/lib.rs +++ b/crates/cli-interface/src/lib.rs @@ -93,7 +93,10 @@ pub fn entrypoint(args: Arguments) -> Result { match res { Some(password) => match std::str::from_utf8(&password) { Ok(password) => { - info!("Success! Found password, displaying as UTF-8: '{}'", password) + info!( + "Success! Found password, displaying as UTF-8: '{}'", + password + ) } Err(_) => { let hex_string: String = password diff --git a/crates/cracker/src/lib.rs b/crates/cracker/src/lib.rs index 9a79fb4..22893a9 100644 --- a/crates/cracker/src/lib.rs +++ b/crates/cracker/src/lib.rs @@ -1,11 +1,11 @@ -use std::{fs, io, cell::RefCell, sync::Arc}; use std::collections::hash_map::HashMap; +use std::{cell::RefCell, fs, io, sync::Arc}; use anyhow::anyhow; -use pdf::PdfError; use pdf::any::AnySync; use pdf::file::{Cache, NoLog, Storage}; use pdf::object::{ParseOptions, PlainRef}; +use pdf::PdfError; #[derive(Clone)] pub struct PDFCracker(Vec); @@ -20,9 +20,7 @@ impl PDFCracker { type ObjectCache = SimpleCache>>; type StreamCache = SimpleCache, Arc>>; -pub struct PDFCrackerState( - Storage, ObjectCache, StreamCache, NoLog> -); +pub struct PDFCrackerState(Storage, ObjectCache, StreamCache, NoLog>); impl PDFCrackerState { /// Init `pdf::file::Storage` so we can reuse it on each `attempt`. @@ -32,7 +30,7 @@ impl PDFCrackerState { ParseOptions::strict(), SimpleCache::new(), SimpleCache::new(), - NoLog + NoLog, ); match res { @@ -43,15 +41,12 @@ impl PDFCrackerState { /// Attempt to crack the cryptography using the password, return true on success. pub fn attempt(&mut self, password: &[u8]) -> bool { - self.0.load_storage_and_trailer_password(password) - .is_ok() + self.0.load_storage_and_trailer_password(password).is_ok() } } /// Single-threaded adapter to use `HashMap` as a `pdf::file::Cache`. -struct SimpleCache( - RefCell> -); +struct SimpleCache(RefCell>); impl SimpleCache { fn new() -> Self { diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index 522bca3..11140d3 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -47,7 +47,7 @@ pub fn crack_file( let c2 = cracker_handle.clone(); let id: std::thread::JoinHandle<()> = std::thread::spawn(move || { let Ok(mut cracker) = PDFCrackerState::from_cracker(&c2) else { - return + return; }; while let Ok(passwd) = r2.recv() { diff --git a/crates/producer/src/default_query.rs b/crates/producer/src/default_query.rs index 3bd8b8c..fb158b2 100644 --- a/crates/producer/src/default_query.rs +++ b/crates/producer/src/default_query.rs @@ -13,14 +13,14 @@ impl DefaultQuery { let mut char_set: Vec = (b'0'..=b'9') .chain(b'A'..=b'Z') .chain(b'a'..=b'z') - .chain(b'!'..=b'/') // Adding special characters from ASCII range ! (33) to / (47) - .chain(b':'..=b'@') // Adding special characters from ASCII range : (58) to @ (64) - .chain(b'['..=b'`') // Adding special characters from ASCII range [ (91) to ` (96) - .chain(b'{'..=b'~') // Adding special characters from ASCII range { (123) to ~ (126) + .chain(b'!'..=b'/') // Adding special characters from ASCII range ! (33) to / (47) + .chain(b':'..=b'@') // Adding special characters from ASCII range : (58) to @ (64) + .chain(b'['..=b'`') // Adding special characters from ASCII range [ (91) to ` (96) + .chain(b'{'..=b'~') // Adding special characters from ASCII range { (123) to ~ (126) .collect(); char_set.sort(); - + Self { max_length, min_length,