Enigma Simulation - End to End

Introduction

This diagram shows of an enigma machine electrical circuit.

image missing

It shows several things the simulation needs to be careful with

Plugboard

The question is "where in the circuit to place the plugboard"?

I found the explanation in Wikipedia

A cable placed onto the plugboard connected letters in pairs; for example, E and Q might be a steckered (plug) pair. The effect was to swap those letters before and after the main rotor scrambling unit. For example, when an operator pressed E, the signal was diverted to Q before entering the rotors.

It seems to indicate that the plugboard was used before and after the rotor scrambling. That is, twice in a circuit. After the pressed key and after the scrambling. This is how I implemented it in my code. It seems to work.

One Possible Enigma GUI

image missing

Internally

list indexes are used by the simulation. Alphabetic characters are only used when getting data from or displaying information to the user. For example:

  1. When the user presses / clicks on / selects an alphabetic character, the character is used to lookup the list-index of that character.
  2. The character's list-index is used internally by the enigma machine simulation. A list-index points to another list-index, that points to another list-index, ...
  3. At the end, the final list-index is converted back to an alphabetic character and displayed to the user.

image missing

Note: lists and list-indexes are faster and simpler to use in the simulation.

Each rotor, reflector, plugboard can be modeled with a Python list. Each rotor, reflector, plugboard is part of an electric circuit. Each has a "in" pins and an "out" pins which, when connected together with their pins touching form an electric circuit. The list's indexes (0-N) are the "in" pins and the list values (0-N) are the "out" pin. The reflector and plugboard are fixed, but the rotors rotate changing the circuit's path.

Each rotor, reflector, plugboard can also be considered a substitution cipher. The list indexes are the "input" characters and the list's values are the "output" characters.

Python Coding

Python lists and dictionaries can be used to simulate the plugboard, rotors, reflector, and keys.

The GUI was created using the Python PySimpleGUI module.