Enigma Machine Simulator

Chiffriermaschine · Instrumentum I of the Sanctum Laboratorium

The Office of Slow Instruments keeps this machine for anyone who wishes to see how a secret was made one letter at a time. Each keypress turns the rotors, sends a current through the wiring and lights a single lamp, and the trace below shows every step of the journey. The Office regards this as the correct speed for encryption.

Type on your keyboard or click keys below · Watch the signal trace through each rotor
Signal Path Visualization

Input

Output

Step-by-Step Trace

Press a key to see the signal path...

Quick Start

  1. Choose your machine variant using the Enigma I (Army/Air Force, 3-rotor) or M4 (Navy, 4-rotor) toggle at the top.
  2. In the configuration panel, select which rotors go in each slot: Rotors I through V on the 3-rotor machine. M4 mode adds the Navy-only Rotors VI, VII and VIII (every naval key included at least one of them), a 4th thin rotor slot (Beta or Gamma) and the corresponding thin reflectors.
  3. Set the ring setting (Ringstellung) for each rotor using the dropdown next to it. The ring setting offsets the wiring relative to the letter on the rotor's visible window; this was part of the daily key.
  4. Click the rotor windows or use the ▲/▼ arrows to set the starting positions. Each click advances the rotor by one letter. This is the operator-chosen starting position used before each message.
  5. Type on your physical keyboard or click the on-screen QWERTZ keys. Each letter is encrypted instantly: the corresponding lamp lights up on the lampboard, and the full signal trace appears below.

Reading the Signal Path

The signal path canvas shows every component of the machine arranged left to right: the input, then each rotor (right → middle → left, and 4th rotor in M4 mode), then the reflector. When you press a key, colored lines trace the electrical signal through the machine:

  1. Gold lines (→ forward path) show the signal entering the rotor bank from the right side. The signal passes through each rotor's scrambled wiring, with vertical curves showing where a letter is substituted inside each rotor.
  2. Teal lines (⟲ reflector) show the signal hitting the reflector at the far end. The reflector swaps the signal to a different contact and sends it back; this is why Enigma is symmetric (the same settings encrypt and decrypt).
  3. Copper lines (← return path) show the signal traveling back through all rotors in reverse order. Because the signal passes through each rotor from the opposite direction, the scrambling is different on the return trip.

The Step-by-Step Trace

Below the signal canvas, the explanation panel provides a text log of exactly what happened at each stage. It starts by showing the rotor positions after stepping, then walks through every transformation: which rotor, which direction (forward or return), and the input→output letter at each stage. This is the heart of understanding Enigma: each rotor is just a substitution cipher, but chaining six passes (three forward, reflector, three return) through rotating wiring creates an enormously complex polyalphabetic cipher.

Understanding the Rotors

Each rotor is a disc with 26 electrical contacts on each side, wired internally so that each input contact connects to a different output contact. When the rotor turns one step, every connection shifts by one position, so the substitution alphabet changes with every single keypress. That's the key insight: unlike a simple substitution cipher where A always maps to the same letter, in Enigma the mapping changes after every character.

The right rotor advances one position before every keypress. When the right rotor reaches its "notch" position (different for each rotor), it causes the middle rotor to advance. The same rule applies to the middle rotor triggering the left rotor. There is also a famous quirk called the double-stepping anomaly: if the middle rotor is at its notch, it steps again on the next keypress along with the left rotor, effectively stepping twice in a row. This simulator faithfully implements this behavior.

The naval Rotors VI, VII and VIII each carry two notches, so they turn their neighbor over twice per revolution: from M to N and from Z to A.

The 4th rotor in M4 mode (Beta or Gamma) does not step at all; it acts as an additional static scrambler, paired with the thin reflector.

Verifying the Simulator: Encrypt, Then Decrypt

Try This 1. In 3-rotor mode, set rotors to I-II-III, reflector UKW-B, rings to A-A-A, starting positions A-A-A (this simulator has no plugboard, which is the same as an empty one)
2. Type HELLO → the output is exactly ILBDA
3. Press RESET ROTORS to return to A-A-A
4. Type the ciphertext ILBDA
5. The output will be HELLO, the original message!

This works because Enigma's reflector makes the machine self-reciprocal: if A encrypts to Z under a given configuration, then Z encrypts to A under that same configuration. So the same machine settings both encrypt and decrypt.

Note: Enigma can never encrypt a letter to itself. If you press A, the lamp for A will never light up. This property, a consequence of the reflector, was actually a crucial weakness that helped the Allied codebreakers at Bletchley Park.

Historical Key Distribution: How Codes Were Shared

The Enigma machine's security depended not just on the device itself, but on a carefully managed system for distributing and changing encryption settings. Both the sender and receiver needed identical machine configurations to communicate. Here is how the Germans organized this in practice.

The Monthly Key Sheets (Schlüsseltafel)

Each Enigma network (Army, Air Force, Navy, and specialized sub-networks) received printed key sheets (codebooks) distributed in advance for an entire month. Each sheet listed the settings for every day of the month in reverse order (day 31 at the top, day 1 at the bottom), so the officer responsible could tear off the current day's strip at the bottom and hand it to the radio operator. After use, the paper strip was destroyed.

Each daily entry on the key sheet specified:

  1. Walzenlage (rotor selection and order): which three rotors to install and in what sequence (e.g., II-IV-V).
  2. Ringstellung (ring settings): the offset of each rotor's internal wiring relative to its visible letter ring (e.g., B-U-L, meaning rings set to positions 2, 21, 12).
  3. Steckerverbindungen (plugboard connections): typically 10 pairs of letters to swap on the plugboard (e.g., AV BS CG DL FU HZ IN KM OW RX).
  4. Kenngruppen (identification groups): three-letter code groups used to help the recipient identify which day's key was used, important when messages arrived late.

The reflector type was usually fixed at the network level and did not change daily. These key sheets were among the most closely guarded secrets in the German military; their capture by the Allies (known as "pinches") was an intelligence windfall of the highest order.

The Message Key Procedure (Post-1940 Army/Air Force)

Using the same daily settings for every message of the day would have given codebreakers too much material encrypted under identical configurations. To prevent this, each individual message used a unique, randomly chosen message key (Spruchschlüssel): a three-letter starting position for the rotors. The procedure worked as follows:

  1. The operator configured the machine per the day's key sheet (rotors, rings, plugboard).
  2. He chose a random three-letter Grundstellung (ground setting), say KVH, and set the rotors to those letters.
  3. He chose another random three-letter message key, say QHM, and encrypted it using the ground setting. This might produce LVA.
  4. He selected one of the day's Kenngruppen from the key sheet (say OOL) and padded it with two random letters to form a five-letter indicator group (e.g., CXOOL).
  5. He then reset the rotors to his message key (QHM) and encrypted the actual message text.
  6. The full transmission, sent via Morse code, looked something like this:
Sample Army/Air Force Message Format U6Z DE C 1500 = 24 = KVH LVA =
CXOOL NIBFL MYMLL UFWCA SCSSN VHAZ=

U6Z = receiving station · C = sending station · 1500 = time · 24 = letter count
KVH = ground setting (sent in clear) · LVA = encrypted message key
CXOOL = Kenngruppe identifier · Remaining groups = the encrypted message body

The recipient would look at the Kenngruppen to identify the correct day's key, configure his machine, set rotors to the ground setting (KVH), decrypt the message key (LVA → QHM), then reset to QHM and decrypt the message body.

The Early Flaw: The Doubled Message Key (Pre-1940)

Until May 1940 the procedure was different, and fatally flawed: the operator typed his chosen message key twice (e.g., QHMQHM) to guard against transmission errors, and sent the encrypted result (say, XMCFZQ) at the start of the message. The rules changed in three phases:

  1. Until 15 September 1938: a fixed daily Grundstellung listed on the key sheet, plus the doubled message key. Every message of the day began from the same ground setting.
  2. 15 September 1938 to May 1940: the operator chose his own Grundstellung and sent it in clear, as in the procedure above, but still enciphered the message key twice.
  3. From May 1940: most networks enciphered the message key only once, the procedure described above.

The repetition created a mathematical pattern: the 1st and 4th letters, 2nd and 5th, and 3rd and 6th were encryptions of the same plaintext letter under related rotor positions. Polish mathematician Marian Rejewski exploited this relationship in December 1932, using permutation group theory to deduce the rotor wirings and break Enigma, a landmark achievement in the history of cryptanalysis.

Kriegsmarine: Even More Elaborate

The German Navy recognized that simpler procedures were vulnerable and employed a significantly more complex system. Their key sheets were split into two parts: internal settings (rotors, rings, thin rotor, reflector: changed every two days) and external settings (plugboard, daily ground position). Instead of operator-chosen message keys, the Navy used a dedicated codebook called the Kenngruppenbuch (K-Book), where operators looked up trigrams and applied an additional layer of bigram substitution using separate tables (Doppelbuchstabentauschtafel). This made the Kriegsmarine Enigma traffic significantly harder to break and was a major reason naval Enigma (particularly the four-rotor "Shark" network used by U-boats) remained unreadable for extended periods during the war.

How the Allies Broke It

The story of breaking Enigma is one of the greatest intellectual achievements of the 20th century. It unfolded in three phases: the Polish mathematical breakthrough, the British industrial-scale codebreaking operation, and the crucial intelligence captures at sea that made it all possible.

Phase 1: The Polish Breakthrough (1932–1939)

Sandwiched between Germany and the Soviet Union, Poland had every reason to monitor its neighbors' communications. In 1929, the Polish Cipher Bureau (Biuro Szyfrów) recruited mathematics students from Poznań University, chosen specifically because the region had been part of Germany before WWI, so the students spoke fluent German. Among them were three young mathematicians who would change the course of history: Marian Rejewski (age 27), Henryk Zygalski (age 24), and Jerzy Różycki (age 23).

The Poles had a critical advantage: a spy. Hans-Thilo Schmidt, a German working in Berlin's Cipher Office, sold documents to French intelligence, including Enigma operating manuals and two months of daily key tables (September and October 1932). The French couldn't make use of them, nor could the British. They passed the material to Poland.

In late 1932, Rejewski made a legendary intuitive leap. He knew the military Enigma's internal entry-disc wiring differed from the commercial version, but had no way to determine the order. He guessed that the Germans, in their methodical way, had simply used alphabetical order: ABCDEFG... rather than the keyboard layout QWERTZ.... He was right. Combined with the spy material and his equations based on permutation group theory, Rejewski reverse-engineered the complete internal wiring of all three rotors and the reflector, without ever having seen the military machine.

The key weakness Rejewski exploited was procedural. At the time, operators encrypted their chosen three-letter message key twice (e.g., typing ABCABC) at the start of each message. This repetition created mathematical relationships between the 1st and 4th, 2nd and 5th, and 3rd and 6th positions. Rejewski developed what he called "characteristics", cycle patterns derived from these relationships, that could be catalogued for every possible rotor configuration.

To automate this cataloguing, the Poles built increasingly sophisticated machines:

  1. The Cyclometer (1934): essentially two Enigma machines wired together, used to build a catalogue of 105,456 rotor setting characteristics. It took over a year to compile. When the Germans changed the reflector in November 1937, the entire catalogue had to be rebuilt from scratch.
  2. Zygalski Sheets (about October 1938): sets of 26 perforated cardboard sheets for each of the six possible rotor orders. When stacked and held up to light, the holes that aligned indicated possible daily key settings. This method was independent of the number of plugboard connections, but like the bomba it relied on the doubled message key.
  3. The Bomba Kryptologiczna (November 1938): Rejewski's electromechanical device containing six sets of Enigma rotors. Six bomba machines (one per possible rotor order) could find daily keys in about two hours. This was the world's first automated cryptanalytic machine.

By early 1938, the Polish team was reading roughly 75% of intercepted German Enigma traffic. Then the Germans struck twice in quick succession. On 15 September 1938 they dropped the fixed daily ground setting: each operator now chose his own and sent it in clear, still followed by the doubled message key. That broke the cyclometer's card catalogue, which depended on every message of the day starting from the same position, and the Poles answered within weeks with the Zygalski sheets and the bomba, both built on the doubled key itself. The real blow came on 15 December 1938, when the Germans issued rotors IV and V: three rotors chosen from five meant 60 possible rotor orders instead of 6. The Poles would have needed 60 bomba machines and ten times as many Zygalski sheets, far beyond their resources.

Facing imminent invasion, the Poles made a momentous decision. At a secret meeting in the Kabaty Woods near Warsaw on July 25, 1939, they revealed everything to stunned French and British delegations: their methods, their machines, the rotor wirings, and a reconstructed Enigma machine for each ally. Gordon Welchman, who would lead Bletchley Park's Hut 6, later wrote that the entire Ultra operation would never have gotten off the ground without what the Poles shared that day. Five weeks later, Germany invaded Poland.

Phase 2: Bletchley Park and the Bombe (1939–1945)

Alan Turing arrived at the Government Code and Cypher School at Bletchley Park on September 4, 1939, the day after Britain declared war. He immediately began working on a fundamentally new approach to breaking Enigma, one that didn't depend on the doubled message key, still in use then but dropped by most networks in May 1940.

Turing's method was built on "cribs": guessed plaintext that the codebreakers believed appeared somewhere in an encrypted message. The insight was that German military communications were full of predictable content: weather reports at fixed times, standard military phrases, message headers like ANX (German for "to" followed by the standard space-replacement X). Operators often began messages with stereotyped openings, and their sign-off habits were equally predictable.

Turing's crucial observation was that since Enigma never encrypts a letter to itself, the crib could be "slid" along the ciphertext until no plaintext letter aligned with the same ciphertext letter at any position. This dramatically narrowed the search space. From the valid alignment, Turing constructed "menus": chains of logical deductions linking rotor positions to plugboard connections.

How a Crib Attack Worked Ciphertext:  DQXTGL VPFKEI...
Guessed crib: WETTER VORHER... (weather forecast)

At each position, check: does any crib letter match the ciphertext letter above it?
If D=W? No. Q=E? No. X=T? No. T=T? Yes: impossible! Slide the crib forward.
Continue until no letter maps to itself → that's a candidate position for the Bombe to test.

Turing's Bombe machine, named in honor of Rejewski's bomba, was an electromechanical marvel. It contained 36 sets of Enigma rotor drums arranged in three banks of twelve, effectively simulating multiple Enigma machines running in parallel. The machine tested candidate rotor positions at high speed, looking for internally consistent plugboard configurations. A critical improvement came from Gordon Welchman, who invented the diagonal board: an elegant addition that exploited the reciprocal nature of the plugboard (if A connects to N, then N connects to A) to massively reduce false positives.

The first Bombe, codenamed "Victory," was delivered to Bletchley Park on March 18, 1940. By August 1940, the improved "Agnus Dei" with Welchman's diagonal board was operational. German Air Force traffic was soon being read regularly. At its wartime peak, over 200 Bombe machines operated at Bletchley Park and its outstations. Nearly 1,700 members of the Women's Royal Naval Service (Wrens) operated the machines in round-the-clock shifts. The United States also built its own version: faster machines manufactured by the National Cash Register Company in Dayton, Ohio, which handled much of the naval Enigma workload.

Turing also made a remarkable discovery by analyzing decrypted messages: the German word "eins" (one) appeared in about 90% of all messages. He created the Eins Catalogue, which pre-computed every possible Enigma encryption of EINS for each rotor position, providing a shortcut that dramatically sped up the crib process.

Phase 3: The Captures at Sea ("Pinches")

Cryptanalysis alone wasn't always enough. The naval Enigma used by U-boats was far more complex than the Army/Air Force version, with additional rotors, separate codebooks, and the elaborate Kenngruppen system described above. Breaking into it required physical captures of key materials (known as "pinches") and these rank among the most dramatic episodes of the war.

The most important pinch came on May 9, 1941, during what became known as Operation Primrose. While escorting convoy OB 318 south of Greenland, the destroyer HMS Bulldog and corvette HMS Aubrietia depth-charged the German submarine U-110, forcing it to surface. Its commander, Kapitänleutnant Fritz-Julius Lemp, ordered his crew to abandon ship, believing the boat was sinking. Commander Joe Baker-Cresswell, instead of ramming the submarine as doctrine called for, made the extraordinary decision to attempt a boarding.

Twenty-year-old Sub-Lieutenant David Balme led a small boarding party across in a whaler boat and climbed down into the abandoned U-boat alone, his pistol holstered because he needed both hands on the ladders. Inside, he found everything intact: the crew had abandoned ship so hastily that nothing had been destroyed. The boarding team recovered a complete naval Enigma machine with all its rotors, the current key sheets, codebooks including the Kurzsignalheft (short signal book), bigram tables, and charts showing U-boat patrol positions and German minefields, all valid for the next three months.

Lemp apparently realized the U-boat wasn't sinking and tried to swim back to destroy the secret materials, but he was lost at sea. U-110 was taken in tow but sank the following day, which actually helped preserve the secret that the materials had been captured. The Germans continued using their codes, unaware of the catastrophic breach. King George VI later called this capture "the most important single event in the whole war at sea."

The impact was immediate and measurable. Before the capture, Allied shipping losses in the Atlantic were running at about 432,000 tons per month. By August 1941, losses had dropped below 80,000 tons, because Bletchley Park could now read U-boat patrol orders and route convoys around the wolfpacks.

The Four-Rotor Crisis and the Shark Blackout

On February 1, 1942, the Kriegsmarine introduced the four-rotor Enigma (M4) for the U-boat fleet, the very machine you can simulate in this tool by switching to "M4 (Navy, 4-rotor)" mode above. Bletchley Park called the new network "Shark." Overnight, naval Enigma went dark. The codebreakers were locked out for nearly ten months, a period known as the "Shark blackout."

During this blackout, Allied shipping losses in the Atlantic surged catastrophically. The Battle of the Atlantic hung in the balance. It took until December 1942 for Bletchley Park to break back into Shark, aided by captured materials from U-559 (seized in the Mediterranean at the cost of two British sailors' lives: Lieutenant Anthony Fasson and Able Seaman Colin Grazier, who drowned when the submarine sank while they were still inside gathering documents). The Americans then designed and mass-produced four-rotor Bombes that could handle the expanded keyspace.

Enigma's Exploitable Weaknesses

Enigma was an impressive cipher device, but several design choices and procedural habits created vulnerabilities that the codebreakers systematically exploited:

  1. No letter encrypts to itself. The reflector's design guaranteed this property. While it made the machine elegantly self-reciprocal (same settings encrypt and decrypt), it gave codebreakers a powerful tool for testing cribs: if any plaintext letter matched the ciphertext letter at the same position, that crib alignment was provably wrong.
  2. The doubled message key (pre-1940). Encrypting the three-letter message key twice created mathematical relationships that Rejewski exploited to deduce the rotor wirings and daily keys.
  3. Predictable message content. Weather reports at fixed times, standard military phrases ("ANX" for "to," "EINS" appearing in 90% of messages), routine situation reports; all provided cribs. The RAF even deliberately planted mines in areas the Germans had swept, forcing them to transmit predictable warning messages (a practice called "gardening").
  4. Lazy operators ("cillies"). Some operators chose easily guessable keys: their girlfriends' initials, keyboard patterns like QAY or WSX, or repeated letters like AAA. At Bletchley Park, these predictable choices were called "cillies", reportedly named after an operator who always used his girlfriend Cilli's name.
  5. Procedural rules that reduced possibilities. The rule that no rotor could remain in the same slot on consecutive days, and that no plugboard cable could connect adjacent letters in the alphabet, both reduced the search space for the Bombes.
  6. Re-encryptions. Messages sometimes had to be sent across networks using different keys. When the same plaintext was encrypted under two different settings, it provided powerful leverage for breaking both.

Ultra: The Intelligence That Changed the War

The intelligence derived from Enigma decrypts was codenamed "Ultra", classified above Top Secret. Its impact spanned virtually every theater of the war. In the Battle of the Atlantic, Ultra allowed convoys to be routed around U-boat wolfpacks. In North Africa, it revealed Rommel's supply lines and battle plans. Before D-Day in 1944, Enigma decrypts provided detailed intelligence on German defensive preparations, helping the Allies confirm that their deception operations were working.

The Ultra secret was guarded so tightly that Allied commanders sometimes had to let attacks proceed even when they knew they were coming, to avoid revealing that the codes had been broken. The full story remained classified until the mid-1970s, thirty years after the war ended. The Polish contribution was suppressed even longer, partly because Poland fell behind the Iron Curtain after the war. Rejewski survived the war but returned to Poland and worked quietly as an accountant. He was not publicly recognized for his role until the 1970s. Różycki had drowned in 1942 when his ship sank in the Mediterranean. Zygalski spent his post-war career teaching mathematics at the University of Surrey in England.

Historians estimate that breaking Enigma shortened World War II by at least two years, saving millions of lives. In 2014, the Institute of Electrical and Electronics Engineers (IEEE) honored Rejewski, Różycki, and Zygalski with its prestigious Milestone Award for their pioneering work, recognizing what many consider one of the most consequential achievements in the history of both mathematics and intelligence.

Key lesson from history: The Enigma machine itself was a reasonably strong cipher device for its era. What ultimately broke it was a combination of procedural weaknesses (the doubled key, predictable message openings like weather reports), the mathematical consequence of the reflector (no letter encrypts to itself), captured materials from daring operations at sea, the industrial-scale automation of codebreaking with hundreds of Bombe machines, and above all, the extraordinary brilliance of the Polish and British codebreakers (aided by thousands of unsung analysts, Wrens, and support staff) who exploited these flaws systematically across six years of war.