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 age of 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.
In particular, this model allows for an aribtrary number of wheels to be used, some of which were not historically used together. All wheels obey an M3/M4-style "double stepping" movement pattern. The smoother gearbox stepping patterns of some later models are not emulated.
Making use
The principle way to use the Enigma module in your scripts is to import and invoke the Enigma 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
Built Distribution
File details
Details for the file python_enigma-1.1.3.tar.gz
.
File metadata
- Download URL: python_enigma-1.1.3.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | de427926eb1e16e2f79b9c2815b96f460abbd2722cc92c4e23e0b6344a70208b |
|
MD5 | 177d1ca8e39a60f76fe36aa4cce11120 |
|
BLAKE2b-256 | 163444e728c02b88a75ab76c06ea21e9d9c7dbf396adfd0e4aaedb635c5104a1 |
File details
Details for the file python_enigma-1.1.3-py3-none-any.whl
.
File metadata
- Download URL: python_enigma-1.1.3-py3-none-any.whl
- Upload date:
- Size: 17.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2fb465973e9e907e1ec2d15c664bd8d5906d877a30ac68b1db0e81c3008308f |
|
MD5 | 9200b6808b2f6f0da41b5e93aa963e1b |
|
BLAKE2b-256 | e9c4152167731eb76fd6cbe0e51f758916f8bc08b3eafd80a80e3926c0b65d32 |