No description
- Python 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
|
||
| .claude | ||
| enigma.py | ||
| LICENSE | ||
| README.md | ||
Enigma Machine Simulator
A Python simulation of the WWII German Enigma I cipher machine with step-by-step encoding visualization.
Quick Start
python3 enigma.py "YOUR MESSAGE"
Usage
python3 enigma.py [options] "message"
Options
| Option | Description | Default |
|---|---|---|
-r, --rotors |
Three rotors (I, II, III, IV, or V) | I II III |
-p, --positions |
Starting positions (3 letters) | AAA |
--rings |
Ring settings (3 letters) | AAA |
--reflector |
Reflector type (B or C) | B |
--plugboard |
Letter pairs, comma-separated | none |
-q, --quiet |
Only show the result | off |
Examples
# Basic encoding with step-by-step output
python3 enigma.py "HELLO"
# Custom rotor order and starting positions
python3 enigma.py -r III II I -p XYZ "SECRET"
# Full configuration
python3 enigma.py -r IV II V -p MCK --rings ABC --reflector C --plugboard AB,CD,EF "MESSAGE"
# Quiet mode (just the encoded result)
python3 enigma.py -q "HELLO WORLD"
Decrypting
Enigma is symmetric. To decrypt, use the same settings:
# Encode
python3 enigma.py -r III I II -p ABC -q "ATTACK"
# Output: WKDHSY
# Decode (same settings)
python3 enigma.py -r III I II -p ABC -q "WKDHSY"
# Output: ATTACK
How It Works
Each letter passes through the machine in this order:
- Rotor Stepping - Right rotor advances; others may follow at notch positions
- Plugboard (entry) - Optional letter swap
- Rotors (forward) - Signal passes right-to-left through three rotors
- Reflector - Bounces signal back
- Rotors (return) - Signal passes left-to-right through rotors
- Plugboard (exit) - Same swap applied again
Run without -q to see each step visualized as letters are encoded.
This project was generated with AI.