Intro
The Enigma Encryption Machine was developed in Germany in the early 1900s and is most well known for its use during WWII. Various websites are dedicated to the history of the Enigma, its evolution over the time and different revisions of the machine. This article's scope is the simulation of one of those revision, as it was developed during the Fall Semester of 2011 at Wentworth Institute of Technology, in C programming language.
Enigma Machine - Computer History Museum, Mountain View, CA
Specifications
One of the strongest point of the Enigma was its interchangeable internal configuration. It had 3-5 moving rotors which could be placed in any order and any alphabetical starting position, a plugboard, which could swap characters before and after the encryption, a reflector which would reverse the rotor's order, and also a few non-desired mechanical glitches which gave an extra step of security to the Germans and delayed the decoding of the machine.
All the above combinations of the Enigma are available online at: http://enigmaco.de.
For our purposes we used the following configurations:
Three rotors
Reflector
Plugboard
Paulette Conditions
Project Development
The code structure can be illustrated as:
Rotor Initialization
Plugboard Input (Optional)Â
Message Input
Encryption
Message Output
Plugboard Output
Encrypted Message Output
The code was developed from inside out starting with step 4, where a character is passed from one rotor to the next, through the reflector and back. At first the code was written for only one character and was later modified for a string of characters, taking under consideration the initial values of the rotors, the offsets introduced after each encryption and also the special Paulette cases discussed below.
Analysis
The main idea is to convert each letter of the input message into its ASCII number and then use that number to locate the corresponding letter of the next rotor.
The initRotor function initializes the rotors starting letter and therefore their initial offset value. The offset values affect the parsing of a character from one rotor to the next and have to be taken under consideration at each input and output stage of a rotor.
The encrypt function returns the position of the desired character with respect to the chosen rotor at the time.
The correct function is used before the encrypt function to ensure that the previous position is still within the ASCII boundaries 65-90 for capital letters A-Z (or 0-25 for a total of 26 characters) and if not it resets it. The above two functions are used in the main character parsing part of the code.
The plugboard is just the English alphabet with swapped characters, therefore we can simply assign the English alphabet to a matrix or string and in case the plugboard option is selected, we modify that string twice, once before the encryption and once after it.
The Paulette cases are three conditions under which the movement of a rotor causes a movement of the next rotor. They are indicated on the above website with a pin between letters V-W for the first rotor, E-F for the second, and Q-R for the third. All these cases and their combinations are taken under consideration in the main part of the code to ensure correct encryption.
Demo
Code
File at the bottom of the page.
Notes
Project for COMP 120, Fall 2011, Wentworth Institute of Technology, Prof. Thomas Goulding, chair of the CS Deparment.