From 727978fbbd1287c77402749d5e57805ff2ef0799 Mon Sep 17 00:00:00 2001 From: Pommaq Date: Fri, 27 Dec 2024 12:59:51 +0100 Subject: [PATCH] cargo fmt project --- crates/cracker/src/lib.rs | 15 +++++---------- crates/engine/src/lib.rs | 2 +- crates/producer/src/default_query.rs | 10 +++++----- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/crates/cracker/src/lib.rs b/crates/cracker/src/lib.rs index 051ab29..8187a38 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, 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> -); +pub struct PDFCrackerState(Storage, ObjectCache, StreamCache>); impl PDFCrackerState { /// Init `pdf::file::Storage` so we can reuse it on each `attempt`. @@ -42,15 +40,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 14d78ec..d3c2048 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,