Experiments - Enigma Machine in a Spreadsheet

Enigma

During the Second World War, the Germans encoded millitary messages using a device called the Enigma Machine. Many messages sent using this machine were successfully decoded by the Allies, and it's been argued that this ability hastened the end of the war.

The device is comparatively simple - after modifying a number of different settings, the user simply types on it as though it were a typewriter. When each letter key is pressed, a light illuminates showing another letter - the result of the cipher process. To encode a message, the user must simply type it on the machine and note down the resulting encrypted letters as they illuminate. Eventually the user has a stream of seemingly garbled characters, which they then transmit to the other party by radio using Morse code. At the other end, the operator sets up their machine in the same way as the originating machine and types in the encrypted text - the letters that show up in the lights on the machine will contain the original unencrypted text. Of course, the hard part for the Allies was determining what machine settings were being used for each transmission - there were many different settings, transmitted between operators in many different ways, and determining these was a mixture of cryptography, espionage and even psychology (some settings were selected by the operator).

My Spreadsheet

Simulating the Engima machine itself isn't too hard a process once you know how it works. For your edification, I have built a spreadsheet which simulates the Enigma machine and can be used to encrypt and decrypt real WWII Enigma messages.

Most of the logic for the encrypting and decrypting is inside the spreadsheet cells themselves, but there is a small amount of VBA code there to help parsing long messages (which are time-consuming to type) and to simulate the stepping of the rotors after each key is pressed.

What are you waiting for? Download the spreadsheet, and declare war on someone!

Chris Rae, 22 Sep 2011