The Enigma Machine, Explained
After reading this you will understand how the Enigma I turned each keystroke into a different letter, why the same settings both encrypt and decrypt, and why the single fact that no letter ever maps to itself was enough to break the whole system.
What the Enigma actually is
The Enigma I was an electromechanical substitution cipher. Press a key and current flows from a battery, through a plugboard, through three spinning rotors, into a reflector, back out through the same three rotors, back through the plugboard, and finally to a lamp that lights the ciphertext letter. Every keystroke is a single substitution, but because the rotors turn after each letter, the substitution changes with every press.
Here is the hook. Type the letter A ten times on a machine with rotors I, II, III, reflector B, all rings at A, all rotors starting at A, and an empty plugboard. You get:
B D Z G O W C X L T
Ten presses of the same key, ten different lamps. That is the point of a rotor machine: a polyalphabetic cipher with a period so long (26 × 25 × 26 = 16,900 before the wiring pattern repeats) that hand analysis of the ciphertext alone is hopeless. The weakness was never the period. It was the wiring's symmetry.
When to study it, and when a simpler cipher is the point
Use this simulator to learn how real rotor cryptography worked, to reproduce settings from wartime key sheets, and to see concretely why key size alone does not equal security. It is a teaching and historical tool. Do not use Enigma to protect anything. It was broken in the 1930s and 1940s, and every modern laptop breaks it in milliseconds.
If you want the gentler roots of substitution, start with the Caesar cipher, then the Vigenère cipher for the first idea of a moving alphabet, and the substitution cipher tool for a single fixed permutation. Enigma is a mechanised, self-inverse, stepping version of those ideas.
The wiring, as a chain of permutations
Treat each component as a permutation of the 26 letters. Let P be the plugboard, R_1, R_2, R_3 the right, middle and left rotors as currently rotated, and U the reflector. The full encryption of one letter is:
Read it right to left as the current's path. P is the plugboard swap on the way in. R_1, R_2, R_3 carry the signal up to the reflector U, which is an involution (it pairs letters, so U = U^{-1}). Then the same rotors in reverse (R_3^{-1}, R_2^{-1}, R_1^{-1}) and the plugboard again bring it back to a lamp.
Two facts follow directly from the algebra. First, because U pairs letters and the return path is the mirror of the outward path, E is its own inverse: E(E(x)) = x. That is why the receiver decrypts with the identical settings. Second, since U never fixes a point (it has no letter paired with itself), E can never map a letter to itself. Encrypt A and you get anything except A. Hold that thought.
Stepping and the double step
Before each letter is enciphered, the rotors advance like an odometer, but with one mechanical quirk. The right rotor steps every keystroke. When the right rotor passes its notch, it kicks the middle rotor. When the middle rotor passes its notch, it kicks the left rotor. The quirk: the pawl that turns the middle rotor also catches it from below, so whenever the middle rotor sits at its notch, the next keystroke steps the middle rotor a second time and the left rotor with it.
The double step means a normal odometer would show far more middle-rotor positions than Enigma actually visits. Instead of 26 × 26 × 26 = 17,576 window states before repeating, the middle rotor's double advance cuts the machine's true period to 26 × 25 × 26 = 16,900. A shorter period is a smaller haystack.
Notch positions are fixed per rotor. Rotor I notches at Q (so the window shows R when the next rotor turns), rotor II at E, rotor III at V, rotor IV at J, rotor V at Z. The mnemonic clerks used was "Royal Flags Wave Kings Above".
A worked example you can reproduce
Encrypting AAAAA with the default settings
Use the demo defaults: rotors I, II, III (left to right), reflector B, ring settings all A (position 01), start positions all A, empty plugboard. Type five As.
- Press 1. Rotors step first: the right rotor goes from
AtoB. Windows readA A B. The signal traces through and lightsB. - Press 2. Right rotor
BtoC, windowsA A C. Lamp lightsD. - Press 3. Windows
A A D. LampZ. - Press 4. Windows
A A E. LampG. - Press 5. Windows
A A F. LampO.
Result: AAAAA becomes BDZGO. Now reset to the same defaults and type BDZGO. You get AAAAA back. That is the self-inverse property in action, not a coincidence. Notice too that none of B, D, Z, G, O equals the letter you typed, because no letter maps to itself.
Reading the wiring diagram and the windows
The live diagram shows one letter's full path. Follow it and you can check the algebra by hand. Watch three things in particular.
- The window letters
- These are rotor positions, the odometer reading. They change every keystroke. They are the part of the key that both stations set at the start of a message.
- The ring setting
- This rotates the internal wiring relative to the window letter. Changing the ring by one shifts where the notch fires and offsets the whole substitution, so
ring A / position Aandring B / position Bare not the same machine. - The plugboard pairs
- Each cable swaps two letters both entering and leaving. With 10 cables, 20 letters are swapped and 6 pass straight through.
The chart below shows why the plugboard looks so strong on paper. It counts the number of ways to place c cables, which is \frac{26!}{(26-2c)! \cdot c! \cdot 2^c}. The count peaks near 11 cables, not at 13.
The fatal flaw and how Bletchley used it
The property that no letter encrypts to itself sounds harmless. It is the crack that the Bombe drove through. Cryptanalysts guessed a crib, a stretch of plaintext likely present, such as WETTERBERICHT (weather report). To line the crib up against the ciphertext, they slid it along and threw out every position where a letter sat above its own encryption, because that alignment is impossible.
A large key space feels like safety. Enigma's plugboard added over 150 trillion combinations, yet the Bombe tested rotor orders and positions and let the contradictions from the no-self-map rule eliminate almost all of them, sidestepping the plugboard entirely. Key size is not security. A single structural regularity can collapse the search.
The interactive below lets you feel the crib-placement step yourself.
Common mistakes when reproducing settings
Most mismatches with a museum machine or a key sheet come from four confusions.
- Ring setting versus start position. Both are letters, both attach to a rotor, and they interact. If your output drifts from a reference by a constant shift, you almost certainly swapped these or set the ring off by one.
- Rotor order direction. Key sheets list rotors left to right as the operator faces the machine. The right rotor is the fast one that steps every keystroke.
- Forgetting the pre-step. Rotors advance before the letter is enciphered, not after. That is why the first output above used window
A A B, notA A A. - Plugboard is symmetric. A cable joining
AandMswaps both ways. There is no direction to it.
If you match the first letter but drift after a dozen or so, suspect the notch and the double step on the middle rotor.
Frequently asked questions
Why does the same setting both encrypt and decrypt?
Because the reflector pairs letters and the return path mirrors the outward path, the whole machine is a self-inverse permutation. Sending a letter through twice with the same starting configuration returns the original. The receiver just sets the same key and types the ciphertext.
Can a letter ever encrypt to itself?
No. The reflector never connects a letter to itself, so the composed permutation has no fixed point. This is provable from the wiring, not a probability. It is exactly the regularity the Bombe exploited.
How big was the real key space?
With three rotors chosen from five, that is 60 orderings. Times 26^3 = 17,576 start positions, times 26^2 = 676 useful ring settings, times about 1.5 × 10^14 plugboard settings with 10 cables. The product is roughly 10^23. The plugboard dominated the count, but the Bombe avoided searching it.
What is the double step in plain terms?
When the middle rotor sits on its notch, it advances on two consecutive keystrokes instead of one, dragging the left rotor with it. This is a side effect of the pawl mechanism. It shortens the machine's period from 17,576 to 16,900.
Is Enigma related to any cipher I already know?
Yes. It is a stepping, self-inverse relative of the polyalphabetic Vigenère cipher, and each single keystroke is a monoalphabetic substitution. If you also enjoy encoding schemes rather than ciphers, the Morse code translator shows how the German operators actually transmitted their ciphertext by radio.