How the Enigma machine works
Every key press first turns the rotors, then sends a current through the plugboard, the three rotors right to left, the reflector, back through the rotors left to right and the plugboard again, where it lights a lamp. Because the rotors move on every press, the same key lights a different lamp each time: AAAAA → BDZGO with rotors I II III at AAA.
The right rotor turns on every press. When it passes its notch it kicks the middle rotor, and the middle rotor kicks the left one. Set the windows to ADU and press three keys to see the famous double step: ADV → AEW → BFX.
How to decrypt an Enigma message
- Set up the machine exactly as the sender did: rotor order, reflector, ring settings and plugboard (the day's key sheet).
- Turn the windows to the starting position (the message key).
- Type the ciphertext. The lamps spell the plaintext. Press 1941 message above to load a real Operation Barbarossa signal from 7 July 1941, already set to its message key
BLA.
Use it in your code
Everything on this page is available as a free, MIT-licensed, zero-dependency npm package with TypeScript types.
npm install @gykh/enigma
import { encryptString, Enigma } from "@gykh/enigma";
encryptString("AAAAA"); // "BDZGO"
const machine = new Enigma({ positions: "ADU" });
machine.press("A"); machine.positions; // "ADV"
Frequently asked questions
Why can a letter never encrypt to itself?
The reflector always sends the current back along a different wire, so a key can never light its own lamp. Codebreakers at Bletchley Park used this flaw to rule out guesses of where a known word (a crib) sat in a message.
What do the ring settings do?
The ring (Ringstellung) rotates a rotor's wiring relative to its letters and notch. It changes the output without changing what you see in the windows, which is why operators needed both the rings and the start positions.
Which machines does this simulate?
The three-rotor Enigma I used by the army and air force, and the navy's M3: rotors I to VIII and reflectors UKW-A, B and C. Its output matches the historical machines letter for letter.
Is my text sent to a server?
No. The whole machine runs locally in your browser. Want to send someone your encrypted message with a short, tidy link? Shorten it with MiniFyn.