Between 1932 and the end of the Second World War, German armed forces sent most of their secret radio traffic through a wooden box about the size of a typewriter. An operator typed a letter, a little lamp lit up with a different letter, and an assistant wrote it down. Press the same key again and a different lamp lit up. Do that a few hundred times and you have a message that, as far as its users were concerned, nobody else could read.
On the machine page you can set up a working Enigma and send coded messages to your friends. This page takes that machine apart, piece by piece, from a single battery and bulb up to the full set of rotors, pawls and cables. By the end, every part of it should make sense.
Lamps and switches
At its heart the Enigma is just an electrical circuit. Each of the 26 keys is a switch, and each of the 26 lamps is a small bulb. Press a key and current flows from a battery, through the switch, along a wire, and into one of the bulbs.
If each key were wired directly to the lamp with the same letter, we wouldn't have much of a cipher. But nothing forces the wires to go straight. Here is a smaller machine with only six letters, whose wires have been scrambled on their way from the keys on the right to the lamps on the left. Click a key, or press A–F on your keyboard:
Current follows the highlighted path, and the lamp at the end of it lights up. Typing a word through this box gives you a substitution cipher: every letter is consistently swapped for another one.
Substitution ciphers are very old and very weak. Since A always turns into the same letter, the most common letter in the ciphertext is almost certainly the most common letter of the language, usually E in German or English. With enough text, a patient person with a pencil can untangle the whole alphabet from letter frequencies alone.
Moving the wires
The fix is to keep changing the scramble. Picture the wiring box as a drum that can rotate. Each wire is fixed inside the drum, but the contacts the drum touches on either side are fixed to the machine. When the drum turns by one position, every wire now connects a different pair of contacts:
In this version the drum advances by one step before each key closes its circuit, and you can see the stripes slide past. Every wire shifts up one contact with each step, and the one at the top comes round to the bottom, because the drum is round: this diagram shows its surface laid flat. Follow the highlighted wire to see where each key's current goes.
Try pressing the same key a few times. The output changes on every press, because the substitution itself changes after every letter. This is a polyalphabetic cipher, and the drum is called a rotor.
The rotor
Here's a real Enigma rotor. This is rotor I, one of five the army issued. You can drag the view around, and use the sliders to turn the rotor and to see inside the bakelite body:
The right side of the rotor carries 26 spring-loaded brass pins, and the left side carries 26 flat brass plates. Inside, 26 wires connect each pin to some plate, in a fixed and secret order. When the rotor sits between two other parts, the pins on one side and the plates on the other press against their neighbours and carry current across.
As you turn the rotor, the pin sitting at the entry contact changes, and so does the plate where the current leaves. Between positions the pins don't touch anything at all. A spring-loaded detent makes sure the rotor always settles squarely at one of the 26 positions.
The rotor also has a few mechanical parts. The serrated thumbwheel lets the operator turn it by hand. The alphabet ring shows the current letter through a little window in the lid, marked here by the red pointer. On the far right there's a ratchet with 26 teeth, and on the far left a notch ring with a single notch cut into its rim. We'll get to those last two soon.
The reflector
A single rotor turning by one step each time isn't very strong. After 26 letters it is back where it started. The Enigma's designers chained several rotors together, and then added a twist: at the far end they placed a fixed reflector (in German, Umkehrwalze) that connects the 26 contacts in 13 pairs. Current enters the reflector, gets sent back through the rotors by a different route, and finally reaches a lamp. Here it is with a single rotor and our six letters:
Current flows in from the key, through the rotor, bounces off the reflector and comes back to a lamp. In the real machine each key is a changeover switch. At rest it connects its letter's wire to that letter's lamp. When pressed, it disconnects the lamp and connects the battery instead. So the same 26 wires carry current both into the machine and back out of it.
The reflector has two important consequences. Try it: if pressing A lights D, then at the same rotor position pressing D lights A. The path is simply traced in reverse. Encryption and decryption are therefore the same operation. To read a message, the receiver set up their Enigma exactly like the sender's and typed in the ciphertext. That made the machine very convenient to use in the field.
The second consequence is less obvious. Since the reflector never connects a contact to itself, current can never come back along the wire it went in on. No letter is ever encrypted as itself. That sounds harmless, but it leaks information: if you guess that a message contains the word WETTERBERICHT ("weather report"), you can immediately rule out every alignment where any letter would sit on top of itself. Codebreakers at Bletchley Park relied on exactly this.
Three rotors
Now let's assemble the full signal path of the Enigma I. Three rotors sit side by side between a fixed entry wheel on the right and the reflector on the left. This is the real wiring of rotors I, II and III and reflector B:
The letters above the rotors are the ones showing in the machine's windows. As you type, the rightmost rotor advances on every key press. When it moves past a particular letter (V for rotor III), it also carries the middle rotor along by one, just like an odometer. Each letter passes through eight rotor wirings plus the reflector, and the whole tangle changes with every key press.
Use the arrows to set the rotors to A A U, then type a few letters and watch the middle rotor tick over as the right one goes from V to W.
The stepping mechanism
I've been saying the rotors "step", but nothing in the machine counts letters. The rotors are pushed around by three little levers called pawls, which are linked to the keys. Pressing any key lifts all three pawls at once. Whether a pawl actually catches anything depends on the notches. Here's the mechanism seen from the front, with the case removed. To make the parts easy to tell apart, I've left out the thumbwheels, painted each rotor's notch ring brass and marked its single notch in blue. The grey sawtooth wheels are the ratchets. All the ratchets are identical; only the notches decide whether a pawl catches.
Drag the key travel slider slowly to see each phase of a key press. First the pawls swing in toward the rotors, then they rise.
The rightmost pawl has nothing to stop it. It always falls onto the ratchet of the right rotor and pushes it around by one tooth, which is exactly 1/26 of a turn.
The other two pawls each sit across a gap between two rotors. Each one is wide enough to reach the ratchet of the rotor on its left and the notch ring of the rotor on its right. Most of the time the pawl rides on the smooth rim of that notch ring. The rim holds it too far out to catch any ratchet teeth, so it rises without effect. Those pawls are drawn in grey, with a red dot where the brass rim stops them: you can see the tip swing in, land on the rim, and slide up past the ratchet teeth without touching them.
But when the notch of the right-hand rotor sits exactly under the pawl, the pawl drops into it and engages. It is now deep enough to catch the ratchet of the rotor on its left, and that rotor moves too. This is how the middle rotor turns over once the right rotor reaches its notch letter.
There is a subtlety here. When the left pawl drops into the middle rotor's notch, it pushes the left rotor's ratchet, but it also pushes on the wall of the notch it is sitting in. So the middle rotor moves as well. Press Set to A D U and then press the key a few times:
ADU → ADV → AEW → BFX
The middle rotor stepped on two consecutive key presses. That is the famous double step. It isn't a feature anyone designed. It falls straight out of the geometry of the pawls. It also means the machine is not quite an odometer: the middle rotor skips a position, and the three rotors cycle through 26 × 25 × 26 = 16,900 positions before repeating, not 26³ = 17,576.
The ring setting
The alphabet ring isn't permanently fixed to the rotor's wiring. It can be slid around the core and clipped in any of 26 positions. This is the ring setting (Ringstellung). On the real rotor, a small dot on the core marks the contact for A, so you can see where the ring sits relative to the wiring. In this rotor the dot is white:
Keep the window showing the same letter and change the ring setting. The letter in the window stays put, but the wiring core rotates under it, and current coming in at A now leaves through a different contact.
The notch is attached to the ring, not to the core. That means the ring setting also changes when a rotor carries its neighbour, relative to the wiring inside. Knowing the window letters alone was not enough to reproduce the encryption. You also needed the ring settings, which were part of the secret daily key.
The plugboard
The last piece is on the front of the machine. The plugboard (Steckerbrett) sits between the keyboard and the entry wheel, and swaps pairs of letters with short double-ended cables. Click one socket and then another to connect them, and click a plugged socket to remove its cable. Then type something:
Current from the key first passes through the plugboard on the way in. If the letter is cabled, it comes out as its partner. After the rotors and reflector, it passes through the plugboard again on the way out. Because each cable swaps both directions, the machine stays its own inverse, and still no letter can encrypt to itself.
The plugboard doesn't move, so on its own it would be just another substitution cipher. But wrapped around the rotors it changes every letter entering and leaving the scrambler. Its contribution to the number of possible settings is huge. With the standard ten cables there are
26! / (6! · 10! · 210) = 150,738,274,937,250
ways to plug the board, which is more than all the other settings combined.
Counting the keys
An Enigma operator had to set up these things before sending a message, usually from a printed monthly key sheet:
- which three of the five rotors to use, and in which order: 5 × 4 × 3 = 60 choices,
- the ring setting of each rotor,
- the plugboard cables: 150,738,274,937,250 choices,
- the starting position of each rotor: 26³ = 17,576 choices.
Multiplied together, ignoring ring settings, that's 158,962,555,217,826,360,000 or about 1.6 × 1020 configurations. The ring settings add more, although they partly overlap with the starting positions.
Checking them one by one was impossible with the technology of the time. The Enigma was broken anyway, first by Marian Rejewski, Jerzy Różycki and Henryk Zygalski in Poland in the 1930s, and later on an industrial scale at Bletchley Park, using Alan Turing's and Gordon Welchman's bombes. They didn't search the whole space. They used the machine's structure against itself. The reflector's "never itself" property, the fact that the plugboard only swaps pairs, guessable phrases in stereotyped messages, and operator mistakes like repeated message keys each let them throw out huge chunks of the space at once.
Your turn
That's the whole machine. Head back to the machine to set one up, using everything on this page: choose and order the rotors, set their rings, plug in the cables, and turn them to a starting position. Then type a message, and send the code to a friend. As long as they set up their machine the same way, the lamps will spell out what you wrote. There's also a message from Bletchley Park waiting there to be decoded.
Open the machine →