Skip to main content

A simple module which adds Enigma Machine-emulating functionality to your python projects.

Project description

python-enigma: Engima Machines, But With Python

This project introduces a package, python_enigma, with an enigma module which can be imported and used to include Enigma-Machine-like encryption to your python project. Also included is a simplistic "Hello World" proof of concept, a basic catalogue of rotors in the jason format expected (catalogue.json), and a convenience script for preparing the catalogue from a csv.

Security Notice

In the gigahertz pocket computing, the Enigma cipher is useful as a point of curiosity only. None of the original security flaws with the Enigma machine as patented have been corrected.

Historical Accuracy Notice

While pains were taken to ensure the interoperability of this emulator and the actual enigma machine, nothing about the module enforces historical accuracy in terms of the use of particular parts or settings, or the "tidying" features of the operator.

Making use

The principle way to use the Enigma module in your scripts is to import and invoke the Engigma class. For convenience, you can read in the string "default" as the catalog list to use the stock catalog included in the module.

The Enigma class accepts the following arguments on initialization:

  • catalog: a dictionary of rotor bindings, or the string "default" to use the stock bindings included in the module.
  • stecker: A space-seperated string of bindings to use for the steckerboard settings. Ex, "AB CD" means that stecker cables are set between A and B, and C and D.
  • rotors: a list of tuples showing the rotor name from the catalog and the desired ringstellung letter setting, ex [("III", "D"),]. Any number of rotors may be used, including duplicates.
  • reflector: a string indicating the name of the rotor from the rotor catalogue which you would like to use for the reflector, ex 'Reflector B'.
  • operator: if True, the operator class will be used. This strips unprintable characters from the message and cuts the message into 5-character chunks.
  • word_length: overrides the length of the words used by the operator.
  • stator: accepts "military" or "civilian", to imitate either the direct encoding of the military version of the device or the QWERTZ encoding used in the civilian model.

Use of the Enigma class provides a variety of convenience methods:

  • set_wheels: accepts a string of wheel positions (as read left to right) and applies them to be the message setting. Should be called before every parse call.
  • set_stecker: if desirable, one could override the steckerboard settings after instantiating the entire machine.
  • parse: parses the string provided and returns that message as though it were processed through an actual Enigma Machine.

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

python_enigma-1.0.0.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_enigma-1.0.0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file python_enigma-1.0.0.tar.gz.

File metadata

  • Download URL: python_enigma-1.0.0.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.7

File hashes

Hashes for python_enigma-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2935c8d0245b2cb75853cb58360d478f26d0a5f525c4d25e8fd17261fa343920
MD5 45cb53c14e957a57d0dc6e0dfdfa8e50
BLAKE2b-256 da3766e9d0227cd3075e2e4a35847501906462a0f3cfffaf4a95516e22fb422e

See more details on using hashes here.

File details

Details for the file python_enigma-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: python_enigma-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.7

File hashes

Hashes for python_enigma-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 33570eff16d66cb6f4918ae8abfec0454bd14cc07be18c0752137a9b4f25bf01
MD5 c088b861411e9fdd5cc0fc073bd7d2d2
BLAKE2b-256 a12b7bb75968993a863ca096bea3eaea932313cde1cc7098b5862cd86e230a5d

See more details on using hashes here.

Supported by

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