Skip to main content

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):

Enigma Transform

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

enigma_simulator-0.2.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

enigma_simulator-0.2.0-py3.9.egg (10.6 kB view details)

Uploaded Source

File details

Details for the file enigma_simulator-0.2.0.tar.gz.

File metadata

  • Download URL: enigma_simulator-0.2.0.tar.gz
  • Upload date:
  • Size: 5.2 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

Hashes for enigma_simulator-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d4608c42fb84b0fe62c716006596a10091ab250fe079d325cd6bdc64569cbd11
MD5 582d41218354f696b2a191f8428bbd71
BLAKE2b-256 370e32a6b2b7cd379998dc312c4d9ad3c244002634556b11505fef9e2dc7c2ce

See more details on using hashes here.

File details

Details for the file enigma_simulator-0.2.0-py3.9.egg.

File metadata

  • Download URL: enigma_simulator-0.2.0-py3.9.egg
  • Upload date:
  • Size: 10.6 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

Hashes for enigma_simulator-0.2.0-py3.9.egg
Algorithm Hash digest
SHA256 78798474188c3175c334818a46ddd79cc0e51f5824c4d8367a27ddebdc71b814
MD5 6cb1506612f18c4d42ffeb6ceb845222
BLAKE2b-256 41ba0705c1ac0fdbf8426a79a28a9cc32fa639d6e33bfda5dec87585dac18c44

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page