This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

A historically accurate Enigma Machine library written in Python 3

Author:Brian Neal <>
Date:June 5, 2012
Home Page:
License:MIT License (see LICENSE.txt)


Py-Enigma is a Python 3 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.


The 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 Example

This 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',
       ring_settings=[1, 20, 11],
       plugboard_settings='AV BS CG DL FU HZ IN KM OW RX')

# set machine initial starting position

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

# decrypt the cipher text with the unencrypted message key

plaintext = machine.process_text(ciphertext)


This program prints:


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

$ --key-file=keys.txt --start=WXC --text='KCH'
$ --key-file=keys.txt --start=BLA --text='NIBLFMYMLLUFWCASCSSNVHAZ'

The format of the key file can be found in the documentation.


Py-Enigma is written in Python, specifically Python 3.2. It has no other requirements or dependencies.


Py-Enigma is available on the Python Package Index (PyPI). You can install it using pip:

$ pip install py-enigma             # install
$ pip install --upgrade py-enigma   # upgrade

You may also download a tarball or .zip file of the latest code using the “get source” link on the Py-Enigma Bitbucket page. Alternatively if you use Mercurial, you can clone the repository with the following command:

$ hg clone

If you did not use pip, you can install with this command:

$ python install


The latest documentation is available at Read the Docs. There you can browse the documentation online, or download it in a variety of formats.

Sources for the documentation are also included in Sphinx format. If you install Sphinx you can generate the documentation in several output formats.


Support is provided at the issue tracker at the Py-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 & References

This software would not have been possible without the thorough and detailed descriptions of the Enigma machine on Dirk Rijmenants’ incredible Cipher Machines and Cryptology website. In particular, his Technical Details of the Enigma Machine page was a gold mine of information.

Dirk has also written an Enigma simulator in 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’s Enigma Museum.

Another good website is The Enigma and the Bombe by Graham Ellsbury.

A nice video which shows the basic components and operation of the Enigma Machine is on YouTube: Nadia Baker & Enigma demo.

Release History

Release History


This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
py-enigma-0.1.tar.gz (37.0 kB) Copy SHA256 Checksum SHA256 Source Jun 6, 2012

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting