# `enigma-rs`

An absurdly fast and highly flexible Enigma machine simulation, encryption, and decryption library for Rust.

## Usage

```bash
cargo add enigma-cipher
```

Example Usage:

```rust
use enigma_cipher::{EnigmaMachine, EnigmaResult, EnigmaBuilder as _};

pub fn main() -> EnigmaResult<()> {
	let machine = EnigmaMachine::new()
		.reflector("B")
		.plugboard("BY EW FZ GI QM RV UX")
		.rotors(1, 2, 3)
		.ring_settings(10, 12, 14)
		.ring_positions(5, 22, 3)?;
	let plaintext = machine.decode("KDZVKMNTYQJPHFXI");
	println!("{plaintext}");
}
```

```bash
cargo run --release
```

## Performance

This crate uses a number of optimization techniques for max performance, including:

- Memoization of certain functions that are called whenever an Enigma machine is created
- Maximum runtime release profile applied by [cargo-wizard](https://github.com/Kobzol/cargo-wizard)
- String storage as `&[u8]` for rapid indexing