An implementation of the Enigma machine in Python.
Project description
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, in this formulation, can therefore be expressed as (from Wikipedia):
Can be used to encrypt/decrypt messages ('X' was used to replace spaces):
from enigma import Enigma
# Encrypting
enigma1 = Enigma(["I", "II", "III"], [0, 0, 0], [0, 0, 0], "B", "AD")
enigma1.encrypt("HELLOXWORLD") # Returns "ILBADSQQAPK"
# Decrypting
enigma2 = Enigma(["I", "II", "III"], [0, 0, 0], [0, 0, 0], "B", "AD")
enigma2.encrypt("ILBADSQQAPK") # Returns "HELLOXWORLD" back
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file enigma_simulator-0.3.0.tar.gz
.
File metadata
- Download URL: enigma_simulator-0.3.0.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d4a57cac29052773d47f5ae044d142acdea5a752ddb0107c0871a17a6631dd3 |
|
MD5 | 2dbe6eb1f5da68c57673b8ff609fd54c |
|
BLAKE2b-256 | f9b11d32250642643f9f491d97daf34e7973193705a00d67a7425b26ca75a244 |
File details
Details for the file enigma_simulator-0.3.0-py2.py3-none-any.whl
.
File metadata
- Download URL: enigma_simulator-0.3.0-py2.py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 2, Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b82ffc19c0b5b0327971022f93749cb248f59723e6c42e8ffe662ea8765a35ae |
|
MD5 | 51096a9363bde24d0762a6cb53ffb1d0 |
|
BLAKE2b-256 | 53c2c1a79ccf661d9eef3de2369cd2ae2ab7fce08668a9f2c7d4810f5711e066 |