py-enigma

A historically accurate Enigma machine simulation library
Download

py-enigma Ranking & Summary

Advertisement

  • Rating:
  • License:
  • MIT/X Consortium Lic...
  • Price:
  • FREE
  • Publisher Name:
  • Brian Neal
  • Publisher web site:
  • https://bitbucket.org/bgneal/

py-enigma Tags


py-enigma Description

py-enigma is a Python library for simulating the Enigma machines used by the German armed forces (Wehrmacht) during World War 2. Py-Enigma makes it possible to both encrypt and decrypt messages that can be sent to, or received from, actual Enigma machines used by the German army (Heer), air force (Luftwaffe), and navy (Kriegsmarine).It is my hope that library will be useful to Enigma enthusiasts, historians, and students interested in cryptography.Py-Enigma strives to be Pythonic, easy to use, comes with unit tests, and documentation.ScopeThe current scope of Py-Enigma is to simulate Wehrmacht Enigma machines. Simulation of other Enigmas, such as the various commercial, railroad, foreign, and Abwher (Military Intelligence) models may come later if there is enough interest and data available.Currently, Py-Enigma can simulate the 3 and 4 rotor Enigma machines used by the German army, navy, and air force.Quick ExampleThis example shows how the library can be used to decode a message using the procedure employed by the German army:from enigma.machine import EnigmaMachine# setup machine according to specs from a daily key sheet:machine = EnigmaMachine.from_key_sheet( rotors='II IV V', reflector='B', ring_settings=, plugboard_settings='AV BS CG DL FU HZ IN KM OW RX')# set machine initial starting positionmachine.set_display('WXC')# decrypt the message keymsg_key = machine.process_text('KCH')# decrypt the cipher text with the unencrypted message keymachine.set_display(msg_key)ciphertext = 'NIBLFMYMLLUFWCASCSSNVHAZ'plaintext = machine.process_text(ciphertext)print(plaintext)This program prints:THEXRUSSIANSXAREXCOMINGXPy-Enigma also includes a command-line application for processing messages. Assuming you have a proper key file that contains the same initial settings as the code above, the above example can be performed on the command-line: pyenigma.py --key-file=keys.txt --start=WXC --text='KCH'BLA$ pyenigma.py --key-file=keys.txt --start=BLA --text='NIBLFMYMLLUFWCASCSSNVHAZ'THEXRUSSIANSXAREXCOMINGXThe format of the key file can be found in the documentation.Product's homepage


py-enigma Related Software