Enigma Daily Settings Generator

enigma-m3-ukw-bBefore attempting this challenge, you should familiarise yourself with the Enigma machine by completing the Enigma Mission X challenge.

Code Books were used by the Germans to list all the settings needed to set up the Enigma machines before starting to encrypt or decrypt messages. The Germans used to change the Enigma settings very regularly (e.g. once a day) so that if the Allies managed to break their code (find out the Enigma settings) they would only be able to use them for that day and would have to find the new settings every day. Code books were highly confidential documents as if a codebook was captured or reconstructed, messages could easily be decrypted.

An Enigma code book would have one page per month. The page would include all the settings for each day of the month with the first day of the month at the bottom of the page so that once used, a setting could be torn off the page.

The settings would indicate which rotors to use and in which order to connect them. Initially the Enigma machine came with a box of five rotors to choose from. On an Enigma M3, three out of the five rotors were connected. The M4 Enigma used four rotors chosen from a box of up to eight rotors.

The settings would also include the wheel settings (how to connect the rotors) and their initial position. Finally the settings would indicate which letters to connect by plugging cables on the plugboard.

The aim of this challenge is to write a piece of Python code to generate a full Code Book of Enigma Daily Settings for the Enigma M3 series. (which consists of 3 rotors to choose from a collection of 5 unique rotors).

The code book should include 30 or 31 set of randomly generated daily settings (one for each day of the month) displayed in a table as follows:

enigma-code-book

Each daily settings should include:

  • The date (number between 1 and 30/31, listed in reverse order)
  • The choice of three rotors (e.g. IV I III)
  • The ring settings (e.g. ABC)
  • The initial rotor positions (e.g. DEF)
  • The plugboard permutations (e.g. AF CK EW MT SV XY)

Python Code / Solution

Share Button
Tagged with: ,