Package: py-enigma
A historically accurate Enigma Machine library written in Python 3Author:Brian Neal <bgneal@gmail.com>Version:0.1Date:June 5, 2012Home Page:https://bitbucket.org/bgneal/enigma/License:MIT License (see LICENSE.txt)Documentation:http://py-enigma.readthedocs.org/Support:https://bitbucket.org/bgneal/enigma/issuesOverviewPy-Enigmais a Python 3 library for simulating theEnigma machinesused
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=[1, 20, 11],
       plugboard_settings='AV BS CG DL FU HZ IN KM OW RX')

# set machine initial starting position
machine.set_display('WXC')

# decrypt the message key
msg_key = machine.process_text('KCH')

# decrypt the cipher text with the unencrypted message key
machine.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.RequirementsPy-Enigma is written inPython, specifically Python 3.2. It has no other
requirements or dependencies.InstallationPy-Enigma is available on thePython Package Index(PyPI). You can install it
usingpip:$ pip install py-enigma             # install
$ pip install --upgrade py-enigma   # upgradeYou may also download a tarball or .zip file of the latest code using the “get
source” link on thePy-Enigma Bitbucket page. Alternatively if you useMercurial, you can clone the repository with the following command:$ hg clone https://bitbucket.org/bgneal/enigmaIf you did not use pip, you can install with this command:$ python setup.py installDocumentationThe latest documentation is available atRead the Docs. There you canbrowse the
documentation online, ordownload it in a variety of formats.Sources for the documentation are also included inSphinxformat. If you
install Sphinx you can generate the documentation in several output formats.SupportSupport is provided at theissue trackerat thePy-Enigma Bitbucket page.
If you have general questions or comments, please feel free to email me (address
at the top of this file).And please, if you use Py-Enigma for anything, even if it is just learning,
please let me know!Acknowledgements & ReferencesThis software would not have been possible without the thorough and detailed
descriptions of the Enigma machine on Dirk Rijmenants’ incredibleCipher
Machines and Cryptology website. In particular, hisTechnical Details of the
Enigma Machinepage was a gold mine of information.Dirk has also written anEnigma simulatorin Visual Basic. Although I did not
look at his source code, I did use his simulator to check the operation of
Py-Enigma.I would also like to recommend the photos and video at Dr. Thomas B. Perera’sEnigma Museum.Another good website isThe Enigma and the Bombeby Graham Ellsbury.A nice video which shows the basic components and operation of the Enigma
Machine is on YouTube:Nadia Baker & Enigma demo.