Thursday is National History Day at our local high school, and just in time for the competition, my son and I put the finishing touches on a German Enigma simulator to complement his display—written, of course, in Silverlight. Here’s what it looks like:

Enigma machines were used to encrypt Axis military communications in World War II. There were many different versions of the Enigma; our simulator models one of the 3-rotor devices. The story of how Polish mathematicians and researchers at Bletchley Park in the UK (including Alan Turing) cracked the Enigma code is both humbling and fascinating. Historians estimate that cracking the code shortened the war by two years.

To encrypt a message, Enigma operators would begin by loading the rotor wheels (represented by the three letters at the top of the screen) into the machine and setting them to a specific code—for example, A-B-C—taken from a code book. Then they would configure the plugboard—the panel with the lettered and numbered jacks at the bottom of the screen—by cabling jacks together. The purpose of the plugboard was to strengthen the encryption by swapping letters. Connect B and C, for example, and a B typed on the keyboard was turned into a C before entering the encryption machinery. (On its way back out, the character resulting from the encryption also went through the plugboard.) Finally, the operator would type the message, and each time a character was typed, one of 26 lamps, one for each character of the alphabet, would light. A second operator would write down the encrypted message by recording the letters that lit up. The Enigma was a symmetric encryption/decryption device, meaning that an encrypted message could be decrypted by setting the machine to the same initial settings used to perform the encryption and typing in the encrypted message.

As characters were typed on an Enigma, the rotor wheels would turn, odometer-style. Because input characters were transposed as they went through the wheels, the same letter would encrypt differently each time it was entered. A simple substitution cipher might encrypt AAAAA as NNNNN. But an Enigma might encrypt the same phrase as YSKLW. Configure the rotors and plugboard differently and it could come out as GTUUK instead.

Our Enigma simulator features a keyboard, a plugboard, an output panel (replacing the 26 lamps), and three rotor wheels. Not visible, but included in the code, is a fourth, non-rotating wheel called a reflector. You can use the up and down arrows above and below the rotor wheels to set the rotors to the desired position, and you can cable plugs together by clicking on an empty plug and dragging the cable that appears to another empty plug. You can delete a cable by clicking it; not yet implemented is the ability to grab one end of a cable and move it to another plug. The simulator uses animations to make the rotors turn, and it uses a MediaElement to play typewriter clicks.

You can try out the Enigma for yourself on Wintellect’s Web site, or you can download the source code and run it locally. For starters, set the rotors to D-A-D and configure the plugboard as shown above, and then type the characters displayed in the output panel to decrypt a secret message from me to you. Enjoy!