No description
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
r3adm3 b9d3785bc2
Add MIT License and note AI generation in README
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 19:23:06 +00:00
.claude feat: Initial Commit? 2026-02-15 19:20:21 +00:00
enigma.py feat: Initial Commit? 2026-02-15 19:20:21 +00:00
LICENSE Add MIT License and note AI generation in README 2026-02-15 19:23:06 +00:00
README.md Add MIT License and note AI generation in README 2026-02-15 19:23:06 +00:00

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:

  1. Rotor Stepping - Right rotor advances; others may follow at notch positions
  2. Plugboard (entry) - Optional letter swap
  3. Rotors (forward) - Signal passes right-to-left through three rotors
  4. Reflector - Bounces signal back
  5. Rotors (return) - Signal passes left-to-right through rotors
  6. Plugboard (exit) - Same swap applied again

Run without -q to see each step visualized as letters are encoded.


This project was generated with AI.