Enigma machine

The cipher machine the German army used through the Second World War, working as it worked: three rotors turning behind a patch panel, a reflector sending the signal back through them, and a different alphabet for every letter you press. Set the wheels and type. The same settings encipher and decipher, because the machine could do nothing else, and no letter ever comes out as itself, which is the flaw that let Bletchley Park read it.

This protects nothing. Enigma was broken in 1932 by Marian Rejewski and read at scale from 1940 onwards, and a laptop breaks it now in seconds. It is here to be understood, not used.

A A A

It is a typewriter whose wiring is scrambled: press A and a different lamp lights.

A wheel turns after EVERY keypress, so the scrambling is different for the next letter. Press A five times and you get five different letters. That is the whole idea, and it is what makes counting letter frequencies useless.

The six settings below are simply how the wiring is arranged before you start. Both operators set their machines the same way each morning from a key sheet, so what one types the other gets back.

Type a message

Machine settings

The machine is already set to rotors I, II and III with everything at A, which is a working machine. Change these only to match a key sheet, or press the 1930 message button above and watch them fill themselves in.

The three rotors
Take three wheels from a box of five and slide them onto the shaft, left to right. Which three, and in what order, is part of the day’s key.
The reflector
The cap at the far end that sends the current back through the wheels along a different path. It is why a letter can never come out as itself.
The ring setting
Each wheel has a lettered ring clipped around it. This is how far that ring is turned relative to the wiring inside, set before the wheel goes in.
The start position
Having loaded the wheels, turn each by hand until the letter you want shows in its window. That is where the message begins.
The plugboard
Cables plugged into the front panel, each swapping two letters both on the way in and on the way out. Ten cables was the usual issue.

The army issued five rotors and used three at a time, in any order. UKW-B was standard from 1937; UKW-A is here because the 1930 manual message uses it.

The ring setting turns the wiring inside each wheel; the start position is what showed through the window when the operator began. Both are three letters, one per rotor, left to right. Up to ten cables, each swapping two letters both ways. Leave it empty for a machine without one.

Why another simulator gives you a different answer

Two Enigma simulators fed the same settings and the same text should agree letter for letter. When they do not, it is almost never a subtle bug. It is one of four disagreements about what the settings mean, and each one has a signature you can read off the output.

What you seeCauseCheck
Every letter is wrong from the first one Rotor order is being read the other way round. Some tools list the rotors right to left, matching the order a letter travels; this page lists them left to right, matching how they sit on the shaft and how a key sheet was printed. Reverse your three rotor choices and try again.
Wrong from the first letter, but reversing the rotors does not fix it Ring setting and start position have been swapped. They are both three letters and they look interchangeable. They are not: the ring turns the wiring inside the wheel, the start position turns the whole wheel. Set every ring to AAA on both machines. If they now agree, that was it.
Correct for a few letters, then diverges and never recovers The other simulator has no double step. This is the commonest fault in Enigma software and it is invisible on short text, which is why so many tools ship with it. Encipher thirty or more letters. A machine without the double step cannot stay correct that long.
Correct except that some letters come back unchanged The other tool is not a real Enigma. A genuine machine cannot map a letter to itself, ever. Encipher AAAAAAAAAA. If an A comes out, stop trusting that tool.

When you need an arbiter rather than an argument, use the worked example from the 1930 Enigma instruction manual. Its plaintext has been published for decades, it is ninety letters long, and it uses reflector UKW-A with settings that make the double step happen more than once. This page loads it from a button and deciphers it correctly; a simulator that cannot is wrong, and the point at which its output stops matching tells you which row above applies.

Decoding a message somebody gave you

Most people arrive here holding a block of letters and a set of settings, from a puzzle, an escape room, a class exercise or a museum. The machine is symmetric, so there is no decrypt button and no separate mode: you set it up exactly as the sender did and type the ciphertext in.

  1. Set the rotors, left to right. A key sheet written II I III means the left wheel is II, the middle is I, the right is III. If your source lists them in the order the current flows, reverse it.
  2. Set the reflector. UKW-B unless told otherwise. It was standard from 1937 and almost every published message uses it.
  3. Set the ring setting. Three letters, often written as numbers on a key sheet: 1 is A, 2 is B, and so on up to 26 for Z.
  4. Set the start position. Three letters, the ones showing in the windows before the first keypress. This is the part that changed per message rather than per day.
  5. Plug the board. A key sheet line like AV BS CG DL FU HZ IN KM OW RX is ten cables. Enter them in any order; a cable works both ways.
  6. Type the ciphertext. Spaces and punctuation are dropped, because the machine had twenty-six keys and nothing else.

If the result is gibberish, the settings are wrong, not the message. Work back up the list: the plugboard is the easiest thing to mistype, and the ring setting is the easiest thing to confuse with the start position.

German operators wrote X for a full stop and spelled numbers out as words, so a correct decipherment often reads like KEINEBESONDEREEREIGNISSEX rather than anything punctuated. Splitting that into words is your job, and it is a good sign rather than a bad one.

How many settings there were, and why that was not enough

Enigma is a useful lesson in the difference between a large key space and a secure one. The army machine's numbers are genuinely enormous.

ChoicePossibilities
Three rotors chosen from five, in order60
Ring settings17,576
Start positions17,576
Plugboard, ten cables150,738,274,937,250
Totalabout 1.6 × 1020

That is more than a hundred million million million. Trying them one per second would take longer than the universe has existed, and the German high command reasoned from exactly that number.

It fell anyway, and none of the reasons were about the size of the key.

  • No letter enciphers to itself. Given a guess at a phrase in the message, you can slide it along the ciphertext and throw away every position where a letter would have to encipher to itself. Most positions die immediately, and what survives is a small enough set to test.
  • The guesses were easy. A weather report went out every morning. Messages ended with HEILHITLER. A quiet outpost sent KEINEBESONDERENEREIGNISSE, nothing to report, day after day. A cipher that is unbreakable in theory is breakable in practice when you already know what it says.
  • The plugboard contributed almost nothing to the attack. It is the source of nearly all of that 1020, and Turing's method was arranged so that a wrong plugboard guess contradicted itself and could be discarded without testing the rest. The largest term in the sum was close to free to strip away.
  • Procedure leaked more than the machine did. Before 1940, operators sent the message key twice at the start of every message, which is what let Marian Rejewski reconstruct the wiring in 1932 with no captured machine at all.

The size of a key space tells you how long a brute-force search would take, and brute force is what an attacker does when nothing better is available. Something better was available here for the whole war.

Frequently asked questions

Is my text uploaded?

No. The machine runs in this tab as you type. The site’s security policy sets connect-src ‘none’, so the browser blocks network requests from these pages, meaning the text could not be sent even if the code tried.

How do I know this is accurate?

It deciphers the worked example from the 1930 Enigma instruction manual, all ninety letters of it, to the plaintext that has been published for decades. That message is long enough for the double step to happen several times, which is the thing most simulators get wrong: a machine without it is correct for the first few letters and then quietly diverges. Press the button to watch it come apart.

What is the double step?

The middle rotor is turned by a pawl that catches a notch on the rotor to its right, and that same pawl rests against the middle rotor’s own notch. So when the middle rotor sits on its notch, the next keypress moves it and the left rotor together, which means the middle wheel advances twice in two presses. It is a consequence of the gearing rather than a design decision, and it is the detail that separates a simulator from a picture of one.

Why can a letter never come out as itself?

The reflector sends the signal back through the rotors along a different path, and a path that returned to where it started would need a wire joining a contact to itself, which no reflector has. It sounds like a small thing. It was the largest single weakness: knowing that a word could not be sitting where it appeared to be let Bletchley Park eliminate huge numbers of possible settings before testing any of them, and the guessed words that made it work were things like the weather report sent every morning.

Who broke it, and when?

Marian Rejewski of the Polish Cipher Bureau reconstructed the wiring mathematically in 1932, years before the war, and Poland handed its work to Britain and France weeks before the invasion. At Bletchley Park, Alan Turing and Gordon Welchman built on it to attack the daily settings at scale. The machines they designed to do it are a direct ancestor of the computer you are reading this on.

Why are there only five rotors?

Because those are the five the army issued. The navy added three more, numbered VI to VIII, which carry two notches each and step differently; supporting them halfway would produce output that looks right and is not, so they are left out until they are done properly.