StringMash.com

Enigma machine simulator

The German cipher machine of the Second World War, wired as the real thing.

Conversion

Enigma is its own inverse: with the same settings, typing the ciphertext gives the message back.

25 characters
Updates as you type

Show the steps
  1. Machine: Enigma I / M3, rotors I IV III (left to right), reflector B, rings PZH, start RTZ, plugboard AD CN ET FL GI JV KZ PU QY WX.
  2. Before each letter the rotors turn, then the current goes through the plugboard, the rotors right to left, the reflector, the rotors left to right, and the plugboard again.
  3. H: rotors at RTA; plugboard H, rotors I U Z, reflector T, back G N Z, plugboard → K
  4. E: rotors at RTB; plugboard T, rotors T N F, reflector S, back P M Y, plugboard → Q
  5. L: rotors at RTC; plugboard F, rotors G K M, reflector O, back F L X, plugboard → W
  6. L: rotors at RTD; plugboard F, rotors H Y C, reflector U, back L X N, plugboard → C
  7. O: rotors at RTE; plugboard O, rotors Y Z I, reflector P, back V K G, plugboard → I
  8. F: rotors at RTF; plugboard L, rotors V R N, reflector K, back A Q B, plugboard → B
  9. R: rotors at RTG; plugboard R, rotors J B D, reflector H, back X S J, plugboard → V
  10. O: rotors at RTH; plugboard O, rotors Y Z I, reflector P, back V K U, plugboard → P
  11. M: rotors at RTI; plugboard M, rotors M P S, reflector F, back N T V, plugboard → J
  12. B: rotors at RTJ; plugboard B, rotors F H X, reflector J, back C E Q, plugboard → Y
  13. L: rotors at RTK; plugboard F, rotors O E B, reflector R, back J B M, plugboard → M
  14. E: rotors at RTL; plugboard T, rotors O E B, reflector R, back J B Y, plugboard → Q
  15. …and 10 more letters.
  16. Enigma is its own inverse: set the machine back to the same start and type the ciphertext to get the message back. It also never turns a letter into itself, a weakness the codebreakers at Bletchley Park used.
  17. 22 letters; the rotors end at RTV.

Using it

Type a message and the Enigma output appears in groups of five letters, as operators wrote it down. Set the machine with the boxes above. Rotors takes three names from I to VIII, left to right, such as I IV III; for the four-rotor naval M4, put Beta or Gamma first and pick a thin reflector. Rings and Start take three letters, or numbers from 01 to 26 as the Army's key sheets printed them. Plugboard takes up to 13 pairs, such as AD CN ET.

To decrypt, keep the same settings and type the ciphertext: Enigma is its own inverse, so the same machine turns the ciphertext back into the message. The page opens on the day key from German Wikipedia's worked example, rotors I IV III, rings 16 26 08 and ten plugboard pairs, so you can follow along with it.

How it works

Each key press first turns the rotors, then sends a current through the plugboard, which swaps letters in pairs; through the three rotors, each a wired disc that scrambles the alphabet; into the reflector, which sends it back; through the rotors again by a different route; and through the plugboard once more to light a lamp. Because the rightmost rotor turns with every key, and the others turn like an odometer's wheels, the scrambling changes with every letter.

The reflector is what makes the machine its own inverse, so one machine could both encrypt and decrypt. It also means a letter can never come out as itself, a flaw the codebreakers used: a guessed word could be ruled out at any position where one of its letters matched the ciphertext.

The double step

Rotors don't turn quite like an odometer. When the middle rotor reaches its own notch, it steps again on the next key press, taking the left rotor with it. Starting from ADU with rotors I II III, the windows read ADV, AEW, then BFX: the middle rotor moved twice in a row. This simulator reproduces that, which is why its output matches the real machines'.

The rotors

RotorWiring (A to Z goes to)Turnover
IEKMFLGDQVZNTOWYHXUSPAIBRCJQ to R
IIAJDKSIRUXBLHWTMCQGZNPYFVOEE to F
IIIBDFHJLCPRTXVZNYEIWGAKMUSQOV to W
IVESOVPZJAYQUIRHXLNFTGKDCMWBJ to K
VVZBRGITYUPSDNHLXAWMJQOFECKZ to A
VIJPGVOUMFYQBENHZRDKASXLICTWZ to A and M to N
VIINZJHGRCXMYSWBOUFAIVLPEKQDTZ to A and M to N
VIIIFKQHTLXOCBJSPDZRAMEWNIUYGVZ to A and M to N
Beta (M4)LEYJVCNIXWPBQMDRTAKZGFUHOSdoesn't turn
Gamma (M4)FSOKANUERHMBTIYCWLQPZXVGJDdoesn't turn

Breaking it

Arthur Scherbius invented Enigma at the end of the First World War, and his firm began selling it in 1923. Around December 1932, Marian Rejewski of the Polish Cipher Bureau used the mathematics of permutations, and flaws in how the Germans sent their message keys, to break the military machine. In July 1939, weeks before the war, the Poles shared their methods and equipment with the British and French.

At Bletchley Park, Alan Turing designed the British bombe in 1939, building on the Polish bomba, and Gordon Welchman added an important improvement in 1940. The intelligence from Enigma and other ciphers, codenamed Ultra, is widely believed to have shortened the war.

Questions

How many settings did Enigma have?

With three rotors chosen from five, the ring settings and ten plugboard pairs, the Army machine had about 159 quintillion (158,962,555,217,826,360,000) settings.

Why does the output skip my numbers and spaces?

Enigma had keys for A to Z only. Operators spelled numbers out and used X for punctuation.

Can I decode a real wartime message here?

Yes, if you know its settings: the rotors, reflector, rings, plugboard and start position.

Sources

Added . What's new