Clever Quest Lab ← Labs

Rotor Cipher Machine

Press a key: the rotors turn, one lamp lights, and you can follow the current through every rotor, stage by stage.

The machine

ReflectorB
Left
Rotor I
A start A
ring 01
Middle
Rotor II
A start A
ring 01
Right
Rotor III
A start A
ring 01

Press any key. With these settings A, A, A, A, A light B, D, Z, G, O.

Tap or click the keys, or type letters A–Z on your keyboard; Backspace takes back the last letter.Tap the keys. ▲ and ▼ turn a rotor’s start position.Click the keys or type A–Z on your keyboard; Backspace takes back the last letter.Type A–Z (arrow keys move between the on-screen keys); Backspace takes back the last letter.

Tape: everything typed so far

Samples:

Only the letters A–Z go through the machine.

Settings (the key)

Left rotor
Middle rotor
Right rotor
Reflector

Signal path of the last key

towards the reflectorback to the lamp
Each column of dots is one set of 26 contacts, A at the top.

    Pairs, not a one-way code

    With the windows at A A A the current pairs the letters like this:

    A key and its lamp always swap places, so the same settings decrypt. No letter is paired with itself.

    Crib placement helper

    A crib is a word you guess is in the message. Wherever a crib letter would sit on the same ciphertext letter, that placement is impossible.

    Each box is one place for the crib: green = possible, grey × = impossible. Click or tap a box to jump there.

    Runs on your device. Nothing you type or record is uploaded. Keeps working without a connection while the page is open. Works with touch. Saves only the machine settings (rotors, rings, start, reflector, plugboard) and display options on this device.

    Added · Updated : FAQ says its sources cover the codebreaking history, not the rotor wiring tables

    How to use it

    This is a working model of the three-rotor machines used by the German armed forces in World War II. Press a key and two things happen: first the rotors turn, then a current runs from the key through the plugboard, the three rotors and the reflector, back through the rotors and the plugboard to one lamp. The lit letter is the ciphertext.

    Everything you type goes onto the tape; you can also paste a text. The machine has only 26 keys, so digits, spaces and punctuation are skipped and letters with diacritics become plain letters (é → E). To decrypt, start from the same settings and type the ciphertext: the plaintext lights up. “Decrypt: run the output again” does this in one press.

    Controls

    How it works

    A rotor is a disc with 26 contacts on each side, cross-wired inside. Number the letters A = 0 to Z = 25. If a rotor’s wiring is W, its window shows p and its ring setting is r, then with k = p − r a letter x leaves the rotor as

    ρ(x) = W(x + k) − k  (mod 26)

    With the plugboard P, the right, middle and left rotors R, M, L and the reflector U, one key press applies, from left to right:

    E = P · R · M · L · U · L−1 · M−1 · R−1 · P

    The plugboard and the reflector only swap letters in pairs, so E is its own inverse: if A lights S, then S lights A, and the same settings decrypt. The reflector never connects a contact to itself, so no letter is ever encrypted to itself, a flaw that helped the codebreakers.

    Stepping. The right rotor steps before every letter. When it steps on from its turnover letter (Q on rotor I, E on II, V on III, J on IV, Z on V), the middle rotor steps too. When the middle rotor stands on its own turnover letter, the next press steps it again together with the left rotor: the double step. So A D U goes to A D V, A E W and B F X. The middle rotor turns once every 25 × 26 = 650 presses, and the windows repeat after 26 · 25 · 26 = 16 900 presses.

    Ring settings. Only the difference p − r changes the wiring; the ring really moves the moment of the turnover. The left rotor passes no turnover on, so its ring adds nothing beyond its start position.

    Settings. There are 5 · 4 · 3 = 60 rotor orders and 26³ = 17 576 start positions. Ten plugboard pairs can be chosen in 26! / (6! · 10! · 210) = 150 738 274 937 250 ways. Together that is 158 962 555 217 826 360 000, about 267; the middle and right rings multiply it by 676.

    Things to try

    Frequently asked questions

    Are these the real wirings?

    Rotors I to V and reflectors B and C follow the wirings published in the historical record, but the Sources below cover the codebreaking history, not the wiring tables themselves. Rotors IV and V were added in December 1938, so operators then chose three of five.

    How was the machine broken?

    In December 1932 Marian Rejewski of the Polish Cipher Bureau worked out the rotor wiring with permutation theory, helped by documents obtained by French intelligence. With Jerzy Różycki and Henryk Zygalski he found ways to recover the daily settings, and in July 1939 the Poles shared their results with French and British codebreakers. At Bletchley Park, Alan Turing designed the bombe, which searched for settings that fit a crib, and Gordon Welchman’s diagonal board sharply reduced its false stops.

    Why does it matter that no letter becomes itself?

    It shows where a guessed word cannot be. A crib had to be placed correctly before a bombe run, and every clash ruled a placement out.

    Is it secure today?

    No. A computer searches the rotor settings quickly and statistics recover the plugboard. Use it to learn, not to protect anything.

    Sources