Encryption with the Enigma Machine
Requires a Wolfram Notebook System
Interact on desktop, mobile and cloud with the free Wolfram Player or other Wolfram Language products.
Germany used the Enigma encryption machine during the Second World War. The machine's alphabet consisted of lowercase letters, a dot, and whitespace, which is represented by the underscore "_". You can set rotors (permutations of the alphabet), reflectors (pairings within the alphabet), and rules (how rotors are rotated during encryption). Those were the fixed parts of the machine. Daily settings included the starting positions of the rotors. Further description is given as the Demonstration works. Choose one of the offered words and see the encryption proceed!
Contributed by: Gasper Zadnik (January 2013)
Open content licensed under CC BY-NC-SA
Each rotor has an ordered alphabet of length at the bottom and a permutation of the alphabet on top. On every rotor, for every letter X, there is a wire connecting X at the bottom to X at the top. Every letter at the top of the rotor is connected to the bottom letter just above it in the rotor or to the point just above it in the reflector, if the rotor is uppermost. In the reflector, there are wire connections between positions (i.e. positions in reflectors are matched in pairs).
When a letter is input to Enigma, the electricity goes through the wires described above (red line in animation). The coded letter is the letter where the electricity leaves the Enigma. After each coding, the rotors are rotated according to the rules. For every letter on each rotor there is a rule that gives the rotation after the coding if electricity goes through this letter. Every day the starting positions of the rotors were changed. You can set the starting position randomly by pushing the button.
When you let time go by slowly, you can see how the electricity passes through the Enigma machine during encryption and how the rotations happen. The last green letter of the picture is the letter that is currently encoding and the red word is the code up to that time. When electricity is in the rotor, the letter on this rotor is figured out on the side. This letter is important when the rotations take place.
Thanks to the reflector, if X is encrypted to Y (given a position of the rotors), Y is encrypted to X (with the same position of the rotors). This ensures that, with a given starting position of the rotors, encrypting some encrypted text will return the original text.
A detailed description of the Enigma machine is given by Graham Ellsbury .
 G. Ellsbury. "The Enigma Machine." (Jan 17, 2013) www.ellsbury.com/enigma2.htm.
"Encryption with the Enigma Machine"
Wolfram Demonstrations Project
Published: January 25 2013