Skip to content
EmadNikPublic

About

A simple Python implementation inspired by the historic Enigma machine.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Enigma

A simple Python implementation inspired by the historic Enigma machine.

Version: v0.0.1


Overview

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.


Features

  • 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.


Project Structure

.
├── enigma.py              # Encrypt / decrypt text
├── today_rotor.py         # Generate today's rotors
├── rotors_today.enigma    # Saved rotor configuration
└── README.md

How It Works

Step 1

Generate a rotor configuration:

python today_rotor.py

This creates:

rotors_today.enigma

which stores all generated rotors.


Step 2

Run the encryption program:

python enigma.py

Example:

>>> Hello-123

Output:

dQ8xL...

Encryption Process

For every valid character:

  1. Character enters Rotor 1
  2. Passes through Rotor 2
  3. ...
  4. Passes through Rotor 12
  5. Hits the Reflector
  6. Returns through Rotor 12 → Rotor 1
  7. Output character is produced
  8. Rotors rotate

Because the rotors rotate after every character, identical input letters usually encrypt to different output letters.


Decryption

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.


Requirements

  • Python 3.10+
  • Standard Library only

No external packages are required.


Warning

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.


Roadmap

Planned improvements include:

  • Plugboard
  • Ring settings
  • Rotor selection
  • Rotor starting positions
  • Configuration files
  • Command-line interface
  • File encryption
  • Better key management
  • Documentation
  • Unit tests

License

MIT License

About

A simple Python implementation inspired by the historic Enigma machine.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages