loading...
Rotor window positions against letters typed (double stepping shows as the middle trace)
running...
The science
The signal path. Each rotor is a fixed scrambling permutation C of the 26 contacts, but it is turned by its window position p minus its ring setting r, so the permutation seen from outside is a cyclic shift conjugate: R = ρk C ρ-k with k = p - r. The current passes the plugboard P, the three rotors, the reflector U, and then back through the rotors and the plugboard:
E = P-1 R1-1 R2-1 R3-1 U R3 R2 R1 P = Q-1 U Q, Q = R3R2R1P
Why the machine is its own inverse and never keeps a letter. The reflector U is a product of 13 disjoint swaps, so U = U-1 and U has no fixed point. E is a conjugate of U, so it has the same structure: E2 = identity (typing the ciphertext with the same key gives the plaintext back) and E(x) is never x. That last property was a weakness: a guessed word (a crib) could be slid along the ciphertext and every position where a letter matched itself could be ruled out.
Stepping and the double-step anomaly. Before each letter the right rotor advances. When the right rotor stands on its notch the middle rotor also advances; when the middle rotor stands on its own notch it carries the left rotor and itself advances. Because the middle rotor steps on two consecutive presses at that moment the sequence ADU, ADV, AEW, BFX, BFY occurs for rotors I, II, III. The period is therefore not 263 = 17,576 but
26 x 25 x 26 = 16,900 letters
Index of coincidence. For a text with letter counts ni and length N, IC = Σ ni(ni - 1) / [N(N - 1)] is the chance that two random positions hold the same letter. English gives Σ pi2 = 0.0655, a flat alphabet gives 1/26 = 0.0385. A single-alphabet substitution keeps 0.066; the Enigma ciphertext drops close to 0.0385 because the substitution changes at every letter. The page reports both and checks the sample text against the standard letter table.
Key space. Rotor order 5x4x3 = 60, window positions 263 = 17,576 and, with k cables, the plugboard count is 26! / [(26 - 2k)! k! 2k]. For k = 10 this is 150,738,274,937,250, and the product is 158,962,555,217,826,360,000 (about 1.6 x 1020). The page evaluates the factorials with exact integers. Ring settings add a further 676 effective values.
Honest simplifications. This is the three-rotor army machine with the historical wirings of rotors I to V and reflectors B and C, an identity entry wheel and one notch per rotor. The navy four-rotor machine, the later rotors with two notches and the settings procedures of the day are not modelled. How the cipher was broken (Rejewski's permutation theory, the Bombe) is not simulated. The index of coincidence uses a 700 letter sample; short texts fluctuate. This is a history and mathematics demonstration of a retired cipher, not a secure cipher for any real use, and it is not affiliated with any museum or manufacturer.