Ciphers & codes

How the Enigma machine worked

The Enigma was the cipher machine of the German armed forces in World War II – and breaking it was one of the greatest feats in the history of cryptography. Here is how rotors, plugboard and reflector work together, why 159 quintillion keys were not enough, and a simulator to try it yourself.

Enigma simulator with rotors I–V, reflector B/C, ring settings, start position and plugboard. Free, in your browser.

Open the Enigma simulator

Parts: keyboard, plugboard, rotors, lamps

The Enigma looks like a typewriter but is really an electrical circuit. Pressing a key sends current through these stations – and a lamp with the ciphertext letter lights up:

  1. Plugboard: cables swap pairs of letters, e.g. A ↔ Q. Ten cables were usual.
  2. Three rotors: each rotor is a disc with 26 contacts on each side, wired criss-cross inside. The army had five rotors (I–V) to choose from, three of which were used.
  3. Reflector: sends the current back along a different path through the three rotors and the plugboard.
  4. Lampboard: shows the encrypted letter.

The trick: before every key press, the right rotor steps one position. After a full turn it takes the middle rotor with it, which in turn moves the left one – like an odometer. So the encryption changes with every letter. Typing A five times with rotors I-II-III at position AAA gives BDZGO.

The daily key

For the recipient to decrypt, their machine had to be set up exactly the same way. The settings came from secret key sheets, new for every day:

SettingExamplePossibilities
Rotor order (which rotors, in which order)II IV I60
Ring settings (wiring relative to the letter ring)12 03 2226³
Start position of the rotorsD K Q26³ = 17,576
Plugboard connections (10 pairs)AQ BW ER …about 151 trillion

Without the ring settings that makes 60 × 17,576 × 150,738,274,937,250 ≈ 159 quintillion (exactly 158,962,555,217,826,360,000) keys. Trying them all was impossible – and yet the Enigma was broken.

Because the reflector mirrors the current along the same path, the Enigma is reciprocal: with the same settings it turns the ciphertext back into the plaintext. Encrypting and decrypting are the same operation.

Set the rotors, type a text – and decrypt it again with the same settings.

The Enigma’s weaknesses

How the Enigma was broken

In 1932 the Polish mathematician Marian Rejewski, with Jerzy Różycki and Henryk Zygalski, reconstructed the rotor wiring – using mathematics (permutation theory) and key documents obtained by French intelligence. In July 1939 the Poles handed their knowledge to the British and French.

At Bletchley Park near London, Alan Turing and Gordon Welchman built on it to create the Bombe, an electromechanical machine that searched rotor positions using guessed pieces of plaintext. From 1940 the Allies read large parts of German radio traffic. The four-rotor naval Enigma M4 (from February 1942) remained a problem until the end of 1942, then it was broken too.

Historians believe the codebreaking shortened the war – and it stayed secret until the 1970s.

Try the Enigma yourself

The Enigma simulator in the tool faithfully reproduces the Enigma I and M3: rotors I to V with their real wiring and notches, reflector B or C, ring settings, start position, plugboard and double stepping. Here’s how:

  1. Choose rotors (e.g. I, II, III), reflector B, ring settings and start position AAA.
  2. Type your text – the ciphertext appears instantly, with the final rotor position below.
  3. To decrypt, enter the ciphertext with the same settings. Out comes the plaintext.

Try the Enigma online

Accurate Enigma I/M3 with double stepping, final rotor position and a printable puzzle sheet. Runs only in your browser.

FAQ

How does the Enigma work, in simple terms?

A key press sends current through the plugboard, three rotating rotors and the reflector back to a lamp. Because the rotors step after every letter, the same letter is encrypted differently each time.

How many keys did the Enigma have?

With 5 rotors to choose from, 26³ start positions and 10 plugboard pairs, about 159 quintillion (1.59 · 10²⁰) – not counting the ring settings.

Who broke the Enigma?

First, in 1932, the Pole Marian Rejewski with Jerzy Różycki and Henryk Zygalski. From 1939/40 Alan Turing, Gordon Welchman and the team at Bletchley Park continued the work with the Bombes.

Why does no letter encrypt to itself on the Enigma?

The reflector always sends the current back on a different contact. This property helped the codebreakers enormously.

Why are encryption and decryption the same on the Enigma?

At every rotor position the encryption swaps pairs of letters. If A becomes G, then at the same position G becomes A.

Is the simulator accurate?

Yes, for the Enigma I and M3: original wiring of rotors I–V, notches, reflectors B and C, ring settings, plugboard and double stepping. With rotors I-II-III at AAA, AAAAA gives the well-known test value BDZGO.

Sources

  1. Enigma machine – Wikipedia.
  2. Crypto Museum: Enigma wiring – wiring of the rotors and reflectors.
  3. Bletchley Park – museum and history of the codebreakers.

Enigma simulator online – free, in your browser.

Open the tool