A simple Python implementation inspired by the historic Enigma machine.
Version: v0.0.1
Enigma is a small experimental encryption project written in Python.
This first version implements a rotor-based substitution cipher inspired by the original German Enigma machine. Every encrypted character changes the internal rotor positions, making identical plaintext characters encrypt differently depending on their position.
The project is intended for learning and experimentation, not for real-world cryptographic security.
- 12 randomly generated rotors
- Rotor stepping after every encrypted character
- Reflector for reversible encryption
- Same function used for both encryption and decryption
- Daily rotor generation
- Supports:
abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789
-
Characters outside this set are copied without modification.
.
├── enigma.py # Encrypt / decrypt text
├── today_rotor.py # Generate today's rotors
├── rotors_today.enigma # Saved rotor configuration
└── README.md
Generate a rotor configuration:
python today_rotor.pyThis creates:
rotors_today.enigma
which stores all generated rotors.
Run the encryption program:
python enigma.pyExample:
>>> Hello-123
Output:
dQ8xL...
For every valid character:
- Character enters Rotor 1
- Passes through Rotor 2
- ...
- Passes through Rotor 12
- Hits the Reflector
- Returns through Rotor 12 → Rotor 1
- Output character is produced
- Rotors rotate
Because the rotors rotate after every character, identical input letters usually encrypt to different output letters.
Encryption and decryption use exactly the same program.
As long as:
- the same rotor file is used
- the rotor positions are identical
running the ciphertext through the program again restores the original plaintext.
- Python 3.10+
- Standard Library only
No external packages are required.
This project is not a secure cryptographic implementation.
It is designed for:
- Learning
- Understanding rotor machines
- Experimenting with substitution ciphers
Do not use it to protect sensitive information.
Planned improvements include:
- Plugboard
- Ring settings
- Rotor selection
- Rotor starting positions
- Configuration files
- Command-line interface
- File encryption
- Better key management
- Documentation
- Unit tests
MIT License