#enigma #settings #decryption #encryption-decryption #ciphertext #rotor #index

enigma-cracker

A start-from-nothing Enigma cipher decryption library for Rust

1 unstable release

0.1.0 Oct 8, 2024

#757 in Cryptography

22 downloads per month

GPL-3.0 license

9KB
138 lines

enigma-cracker

A start-from-nothing Enigma cipher decryption library for Rust.

enigma-cracker finds the most likely rotor settings, ring settings, and plugboard by brute forcing them one at a time and performing various cryptographic analysis techniques on the results.

Naturally, the crate can't perfectly identify the "correct" plaintext, so it relies on statistics like index of coincidence; Thus, it'll be more accurate with longer ciphertexts.

Usage

cargo add enigma-cracker
use enigma_cracker::crack_enigma;

fn main() -> EnigmaResult<()> {

	let ciphertext = include_str!("cipher_file.txt");
	let plaintext = crack_enigma(ciphertext);

	Ok(())
}
cargo run --release

Performance

The performance of this crate varies wildly by ciphertext length; Since Enigma machines decrypt character by character, the decryption process is O(n). This crate needs to perform several million decryptions, so longer ciphertexts can drastically increase runtime.

Make sure you run in release mode; The difference between debug and release mode can be over 10x in speed.

I also recommend using cargo-wizard to optimize your release profile for maximum runtime performance.

Dependencies

~0.5–10MB
~62K SLoC