Skip to main content

Enigma Simulator

An implementation of the Enigma machine in Python. Simulates a common 3-rotor machine with the common 8 rotors and 3 reflectors. Wikipedia has a good overview. Project inspired by this video.

The transformation of each letter is implemented as a product of permutations (Rejewski, 1980), in this case 26x26 matrices. The transform, E, in this formulation, can therefore be expressed as:

Enigma Transform

where P is the plugboard, L, M and R are the left, middle and right rotors respectively, U is the reflector and p is the cyclic permutation of the mapping of A to B, B to C, etc. a, b and c are the rotations of each rotor as caused when a key was pressed.

Can be used to encrypt/decrypt messages ('X' was used to replace spaces) as such:

from enigma_simulator.enigma import Enigma


# Encrypting
enigma1 = Enigma(["I", "II", "III"], [1, 1, 1], "B", "AD", [0, 0, 0])
enigma1.encrypt("HELLOXWORLD") # Returns "LOFUHZZLZOB"

# Decrypting
enigma2 = Enigma(["I", "II", "III"], [1, 1, 1], "B", "AD", [0, 0, 0])
enigma2.encrypt("LOFUHZZLZOB") # Returns "HELLOXWORLD" back

Release files for enigma-simulator 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for enigma-simulator 0.4.0
File Size Uploaded
enigma_simulator-0.4.0.tar.gz 5.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for enigma-simulator 0.4.0
File Interpreter ABI Platform
enigma_simulator-0.4.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size:11.7 kB

Release files / enigma_simulator-0.4.0.tar.gz

Download URL enigma_simulator-0.4.0.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2c175d41744c70450d556a590fd7fe98209126363058703be4589bc278ead2b4
BLAKE2b-256 checksum
How to use checksums
314e96071b4cbf86343cae8bbb5a34f69cff3460131a5a3b08666ba2fd15bde4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.0

Release files / enigma_simulator-0.4.0-py2.py3-none-any.whl

Download URL enigma_simulator-0.4.0-py2.py3-none-any.whl
Size 6.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
06e1553fa1b7038982e7873a4daf31a9e968cf75bdb26b1390fbe85ac0371d40
BLAKE2b-256 checksum
How to use checksums
a16932edaf262c22051c113fc6329c525c921bfa694aa36dc84ce282cd3618a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.0

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page