pdfrip icon indicating copy to clipboard operation
pdfrip copied to clipboard

Inline bits of pdf crate for better performance

Open jorpic opened this issue 10 months ago • 0 comments

Hello and thank you for this project, it helped me A LOT recently.

I was in a need to restore passwords for multiple PDF documents, so performance was really important. It occurs that sharing single pdf::file::Storage between attempts in a single thread results in a noticeable speedup.

Cracking one of the example files on my machine:

  • 6113 vs 2269 attempts/s for single thread
  • 14315 vs 6095 attempts/s for four threads

Single thread

user@zen ~/t/pdfrip (inline-pdf-storage)> cargo run --release -- -n 1 -f examples/default-query-1.pdf range 1 1000000
 2024-04-22T17:23:26.430Z INFO  engine > Starting password cracking job...
  [00:02:43] [████████████████████████████████████████]  999999/999999  100% 6113/s ETA: 0s
 2024-04-22T17:26:10.043Z INFO  cli_interface > Failed to crack file...
user@zen ~/t/pdfrip (main) [1]> cargo run --release -- -n 1 -f examples/default-query-1.pdf range 1 1000000
 2024-04-22T17:36:11.308Z INFO  engine > Starting password cracking job...
  [00:07:20] [████████████████████████████████████████]  999999/999999  100% 2269/s ETA: 0s
 2024-04-22T17:43:32.091Z INFO  cli_interface > Failed to crack file...

Four threads

user@zen ~/t/pdfrip (inline-pdf-storage) [1]> cargo run --release -- -n 4 -f examples/default-query-1.pdf range 1 1000000
 2024-04-22T17:28:08.219Z INFO  engine > Starting password cracking job...
  [00:01:09] [████████████████████████████████████████]  999999/999999  100% 14315/s ETA: 0s
 2024-04-22T17:29:18.090Z INFO  cli_interface > Failed to crack file...
user@zen ~/t/pdfrip (main) [1]> cargo run --release -- -n 4 -f examples/default-query-1.pdf range 1 1000000
 2024-04-22T17:32:44.111Z INFO  engine > Starting password cracking job...
  [00:02:44] [████████████████████████████████████████]  999999/999999  100% 6095/s ETA: 0s
 2024-04-22T17:35:28.198Z INFO  cli_interface > Failed to crack file...

jorpic avatar Apr 22 '24 18:04 jorpic