The Enigma machine: how it worked and how it was broken
For six years, every day, thousands of German operators typed messages on a keyboard that looked like a typewriter's, watching small lamps light up. On harbour quays, in trenches, in submarines in the Atlantic, in headquarters offices. They were convinced, and so were their commanders, that nobody in the world could read what they wrote.
They were wrong. But not because the machine was weak.
This is the story of Enigma: who invented it, how it worked piece by piece, why it seemed unbreakable and how it was broken. It is also a story closer to my line of work than it might seem, because Enigma was not defeated by mathematics alone. It was defeated by the habits of the people who used it.
From a machine for banks to a secret weapon
Enigma was not born as a military tool. It was born as a commercial product.
On 23 February 1918 the German engineer Arthur Scherbius filed a patent for a rotor cipher machine. The idea was not his alone: in the same years, inventors in the Netherlands, Sweden and the United States were working on similar devices. The principle was in the air. Scherbius's achievement was to turn it into a product.
In 1923 his company, Chiffriermaschinen AG in Berlin, began selling the machines under the name Enigma. The intended customers were banks, businesses and offices wanting to protect telegrams and commercial correspondence. The first models printed their output; from 1924 came the lamp models, smaller and simpler, which would become the classic form.
Civilian sales were not a success. The customer that changed everything was the German state:
| Year | Event |
|---|---|
| 1918 | Arthur Scherbius's patent (23 February) |
| 1923 | First use of the name Enigma and commercial sales |
| 1926 | The German navy adopts an adapted version |
| 1927–1928 | Army and air force adopt Enigma; the plugboard is developed |
| 1930 | The military Enigma I, with plugboard, enters service (1 June) |
| 1938 | From 15 December the army's rotor set grows from three to five |
| 1942 | On 1 February U-boats switch to the four-rotor Enigma M4 |
| 1944 | The rewirable reflector UKW-D appears (January) |
Scherbius saw none of this: he died in an accident in 1929. According to the Crypto Museum, more than 20,000 Enigma machines were built in total.
How Enigma worked, piece by piece
From the outside, the military Enigma is a wooden box with a 26-letter keyboard, a panel of 26 lamps laid out the same way and, at the front, a row of sockets connected by cables. Inside, the heart of the machine is three discs side by side: the rotors.
The operator presses a letter. A lamp lights up with another letter. A second operator writes it down. That is all, apparently. The point is that the same letter, pressed twice in a row, almost always lights two different lamps.
The path of the signal
Each key press closes a battery-powered electrical circuit. The current makes this journey:
- Keyboard. The pressed key sends current down that letter's wire.
- Plugboard (Steckerbrett). If the letter is cabled to another, they swap. With A cabled to K, A becomes K and K becomes A.
- Entry wheel (Eintrittswalze). A fixed disc that passes the signal to the rotors.
- Three rotors, right to left. Each rotor is a disc with 26 contacts on each face, wired together internally in a scrambled pattern. Each rotor therefore replaces one letter with another.
- Reflector (Umkehrwalze). A fixed disc that receives the signal from the last rotor and sends it back on a different contact.
- The three rotors again, this time left to right, along a different path.
- Entry wheel and plugboard, crossed again.
- Lamp. The enciphered letter lights up.
In a single stroke the letter goes through up to nine substitutions: plugboard, three rotors, reflector, three rotors, plugboard.
Why the cipher changed with every letter
The trick that set Enigma apart from a simple substitution code is movement. Before the current flows, pressing the key advances the right-hand rotor by one position. The internal wiring shifts relative to the contacts and the substitution changes completely.
When the right-hand rotor reaches its turnover point, a notch on its ring also advances the middle rotor, like an odometer. The middle rotor in turn advances the left-hand one. Each rotor had its notch in a different place: rotor I advanced its neighbour when moving from Q to R, II from E to F, III from V to W, IV from J to K, V from Z to A.
There was also a mechanical quirk, known as double stepping: because of how the mechanism was built, the middle rotor in certain positions advanced on two consecutive key presses. As a result the sequence of positions repeats after 16,900 letters (26 × 25 × 26), not after 17,576 as one might expect.
The ring and the starting position
Each rotor had an outer ring with the letters of the alphabet, visible through a small window. The ring could be turned relative to the internal wiring: this was the ring setting (Ringstellung). It moved the point at which the rotor advanced its neighbour, and it decoupled the letter shown in the window from the actual wiring.
To encipher, the operator therefore had to set four things: which rotors to use and in what order, the ring settings, the plugboard connections, and the rotors' starting position.
The reflector: strength and flaw
The reflector was an elegant idea. Because the signal travels back through the same machine, Enigma is reciprocal: if with a given setting A becomes G, with the same setting G becomes A. Enciphering and deciphering were the same operation. The receiver set up the machine like the sender and typed the ciphertext: the lamps returned the plain message.
The price was an iron rule: no letter could ever be enciphered as itself. An A never became A. It looked like a detail. It turned out to be a decisive crack.
How "secure" Enigma was, in numbers
For the army's standard military Enigma, with three rotors chosen from five and ten plugboard cables, the count of possible settings is:
| Component | Possibilities |
|---|---|
| Choice and order of 3 rotors from 5 | 60 |
| Starting positions of the rotors (26 × 26 × 26) | 17,576 |
| Connections with 10 plugboard cables | 150,738,274,937,250 |
| Total | 158,962,555,217,826,360,000 |
That is about 1.6 × 10^20 settings. Trying them all, by hand or with the machines of the time, was unthinkable. And here lies Enigma's first lesson: the number of settings does not measure security. The attacks that worked did not try every key. They used the machine's structure and its users' mistakes to rule out almost all of them.
Note also that the plugboard on its own contributes by far the largest share of that number. But it is also the part that does not change during a message: codebreakers learned to "separate" it from the rotor problem.
How it was used: daily keys and message keys
Operators did not choose the settings. They were distributed on monthly key sheets, one line per day: rotor order, ring settings, plugboard connections. They were printed so they could be destroyed quickly, because losing one to the enemy meant compromising a month of communications.
If every message on a given day had been enciphered with exactly the same setting, an opponent would have had hundreds of texts enciphered the same way. To avoid this, each operator chose his own starting position of the rotors for each message, the message key, and sent it enciphered at the start of the message.
For years, under army procedures, the message key was enciphered twice in a row, as a safeguard against transmission errors. From a radio operator's point of view it was a sensible precaution. From a security point of view it was a gift: every message began with six letters in which the first and fourth, second and fifth, third and sixth concealed the same letter. This is exactly where the Poles started. The repetition was dropped in spring 1940, but by then the damage was done.
The first to break it: the Polish mathematicians
Poland had more reason than any other country to read German communications. At the end of the 1920s the Polish Cipher Bureau (Biuro Szyfrów) made what was then an unusual decision: instead of relying only on linguists and puzzle experts, it recruited young mathematicians from the University of Poznań.
Among them were Marian Rejewski, Jerzy Różycki and Henryk Zygalski.
December 1932: Rejewski reconstructs the machine
At the end of 1932 Rejewski tackled the military Enigma without ever having seen one. He started from the six opening letters of the messages and the relationships between the first and fourth, second and fifth, third and sixth. Using permutation theory, a branch of algebra, he wrote a system of equations describing the rotor wiring.
Mathematics alone would not have been enough. He received decisive help from French intelligence: an employee of the German cipher office, Hans-Thilo Schmidt, was selling documents to the French. Captain Gustave Bertrand passed operating manuals and some monthly key sheets to the Poles. With those keys in hand, Rejewski could isolate the unknowns and, in December 1932, reconstruct the rotor wiring. The Poles then built working replicas of the machine.
Machines to find the keys
Reconstructing the machine was not enough: every day the day's key had to be found. The Poles invented increasingly powerful tools:
- the cyclometer (around 1934–1935), with which Rejewski compiled a catalogue of the "fingerprints" left by each rotor position;
- the cryptologic bomb (bomba kryptologiczna, autumn 1938), an electromechanical machine that automatically searched for rotor positions consistent with the messages; six were built;
- Zygalski sheets, perforated sheets that, stacked on a light table, revealed the correct key where light passed through every hole.
On 15 December 1938 the Germans added two rotors, raising the choice from three to five. The possible rotor orders rose from 6 to 60, and Polish resources were no longer enough.
July 1939: handing over the work
With war approaching, at the end of July 1939, at a site near Warsaw, the Poles showed a British and a French delegation everything they had achieved: methods, devices and replicas of the machine. The Allies, who until then had been unable to read military Enigma, received years of work in a few days.
A few weeks later Germany invaded Poland. The Polish codebreakers escaped and carried on working in France.
Bletchley Park and the Bombes
In Britain the work was concentrated at Bletchley Park, a country estate north of London where the Government Code and Cypher School had moved. Among those who arrived there were the mathematician Alan Turing, Gordon Welchman and the cipher expert Dilly Knox.
Turing's idea: start from a probable word
The Polish approach relied on the repeated message key, which the Germans would sooner or later drop. Turing looked for a method that would work regardless. He found it in cribs: words that were likely to appear in a message.
Military messages were full of recurring formulas: weather reports with the same structure every day, standard headings, phrases like "nothing to report". If one assumed that a stretch of ciphertext matched a certain word, one obtained a set of constraints on the rotor positions.
This is where the reflector's flaw came in. Since no letter could become itself, the word could be slid along the ciphertext and every position where a letter matched itself could be discarded at once.
The Bombe
To test the constraints Turing designed an electromechanical machine, the Bombe, named after the Polish device but based on a different principle. The Bombe simulated many interconnected Enigmas and spun their rotors at high speed, stopping only at positions consistent with the crib. The surviving positions were then checked by hand.
The first Bombe, named Victory, was delivered to Bletchley Park on 18 March 1940. It was built by the British Tabulating Machine Company under the engineer Harold Keen. Gordon Welchman then proposed an improvement, the diagonal board, which exploited the reciprocity of the plugboard and made the machine far more effective: the first Bombe with it arrived on 8 August 1940.
The human factor, again
Bombes alone were not enough: reliable cribs were needed. And German operators supplied them without knowing it. Lazy message keys, such as three identical letters or adjacent letters on the keyboard. Routine messages repeated every day at the same time. The same text sent on two different networks, one of which was already broken.
At Bletchley Park they learned to recognise individual operators' habits, almost like handwriting. It is what we now call behavioural profiling, and it is the same reason people are still the weakest link in any security system.
The war in the Atlantic: naval Enigma and "Shark"
The German navy was the most careful user of Enigma. Its machines could choose from eight rotors instead of five, giving 336 possible orders for three rotors, and its procedures were stricter. Reading its traffic was vital to the Allies: German submarines were sinking the convoys that supplied Britain.
An important part of the work came from captures of cipher material. On 9 May 1941 the Royal Navy captured the submarine U-110 before it sank, recovering a machine and documents. Material was also seized from German weather ships in the same period.
On 1 February 1942 the U-boats switched to the Enigma M4, with a thin fourth rotor (called Beta or Gamma) that did not move during encipherment but multiplied the possible positions by 26. The U-boat network, which the Allies called Shark, went dark for almost a year, during the hardest phase of the Battle of the Atlantic.
The breakthrough came on 30 October 1942. As the crew abandoned the submarine U-559 in the eastern Mediterranean, Lieutenant Anthony Fasson and Able Seaman Colin Grazier went into the sinking hull and passed cipher documents out, recovered with the help of the very young canteen assistant Tommy Brown. Fasson and Grazier drowned and were awarded the George Cross. The documents, including the codes for short weather messages, provided the cribs that allowed Shark to be read again in December 1942.
From 1943 US Navy Bombes also came into service, built by the National Cash Register Company in Dayton, Ohio, faster and suited to four-rotor keys.
Italy and the Battle of Cape Matapan
The Italian Royal Navy also used Enigma, in the commercial version without a plugboard. It was far more vulnerable, and Dilly Knox's team at Bletchley Park worked on its messages.
In the second half of March 1941 the young codebreaker Mavis Lever (later Batey) deciphered messages announcing an Italian fleet operation against British convoys bound for Greece. Admiral Cunningham was able to intercept the fleet. At the Battle of Cape Matapan, from 27 to 29 March 1941, the Italian navy lost three heavy cruisers, Zara, Fiume and Pola, and two destroyers. About 2,300 Italian sailors died.
To protect the source, the British made sure the Italian fleet was "spotted" by a reconnaissance aircraft. This was the rule of Ultra, the name given to intelligence derived from decrypts: every piece of information needed a credible alternative explanation, so the enemy would not suspect Enigma had been broken.
And Switzerland?
Neutral Switzerland also enciphered with Enigma. According to the Crypto Museum, between 1938 and 1940 the Swiss army bought commercial Enigma K machines, without a plugboard, and had their rotors rewired to distinguish them from those on sale. By July 1942, 265 were in use: 102 with the army and 163 with the air force. The foreign ministry used machines on loan from the army.
It was not enough. The British codebreaker John Tiltman was reading Swiss diplomatic traffic from September 1939, and German services were also deciphering Swiss diplomatic communications. After the French broke part of the traffic in 1941, the army changed the way the rotors stepped.
In the end Switzerland chose to build its own machine: the NEMA (Neue Maschine), which entered service in 1946 and replaced the Enigma K.
The longest secret
By the end of the war Bletchley Park had nearly 10,000 staff, 75% of them women: Bombe operators, translators, analysts, codebreakers like Mavis Lever (Bletchley Park). All had signed a secrecy undertaking, and almost all kept it for decades. Many never told family and friends what they had done in the war.
The world began to find out only in the 1970s: in 1973 Gustave Bertrand published his memoirs in France, and in 1974 Frederick Winterbotham's book The Ultra Secret brought the story to a wide audience. The Polish role was fully recognised even later.
Alan Turing did not live to see this recognition. Convicted in 1952 for homosexuality, then a crime in the United Kingdom, he died in 1954. He received a posthumous royal pardon in 2013.
How much did Enigma weigh on the outcome of the war? The question is still debated. The official historian of British intelligence, Harry Hinsley, estimated that the decrypts shortened the war by at least two years. Other historians urge caution: information is only worth something if someone is able to act on it. What is certain is that without Ultra the Battle of the Atlantic would have been far longer and costlier.
Three myths to dispel
"Alan Turing broke Enigma on his own." No. The first decisive step was Polish, and thousands of people worked at Bletchley. Turing was a central figure, not the only one.
"Enigma was broken by the first computer, Colossus." No. Colossus was built for the Lorenz cipher, a different machine used by the German high command. Enigma was attacked with Bombes, which were not programmable computers.
"Enigma was a weak machine." No. Used flawlessly, it would have been very hard to break with the means of the time. It was broken through a combination of three factors: a design flaw (no letter enciphered as itself), procedural errors (the repeated key, standard messages) and material captured or supplied by spies.
What Enigma teaches today
I read the Enigma story through the eyes of my profession, and the lesson seems crystal clear to me: a security system is only as good as the habits of the people who use it.
The Germans had a machine with 10^20 settings, and they betrayed it by repeating the key, sending the same weather report every morning, choosing three identical letters as a key. Today companies have encryption, firewalls and two-factor authentication, and they are breached because an employee clicks a link, reuses a password or answers a convincing phone call.
It is the same principle behind the cybersecurity awareness training I run for companies: technology only protects you if people know how it gets attacked. For readers interested in the historical side, the archive also has an article on Cold War espionage techniques, and historical research is one of the services I offer to individuals, institutions and scholars.
Frequently asked questions
Who invented the Enigma machine?
The German engineer Arthur Scherbius, who filed his first patent on 23 February 1918. The name Enigma appeared in 1923, when his company began selling the machines for civilian use. Only later did the German navy, army and air force adopt military versions.
How many settings did Enigma have?
In the standard military version, with three rotors chosen from five and ten plugboard cables, there were 158,962,555,217,826,360,000 possible settings, about 1.6 × 10^20. The figure is misleading, though: real security also depended on how operators used the machine.
Who broke Enigma first?
The Polish mathematician Marian Rejewski, in December 1932, at the Polish Cipher Bureau. With his colleagues Jerzy Różycki and Henryk Zygalski he developed methods and devices that were shared with the British and French in July 1939.
Did Alan Turing break Enigma with the Colossus computer?
No. Colossus was built at Bletchley Park to attack the Lorenz cipher used by the German high command, not Enigma. Enigma was attacked with Bombes, electromechanical machines designed by Turing and improved by Gordon Welchman.
Why did Enigma never encipher a letter as itself?
Because of the reflector, which sent the signal back through the rotors along a different path. The reflector made the machine reciprocal, but it also meant no letter could ever become itself. That rule let codebreakers rule out many possibilities.
Did Switzerland use Enigma?
Yes. The Swiss army and air force bought commercial Enigma K machines between 1938 and 1940 and had their rotors rewired. By July 1942, 265 were in use. They were replaced in 1946 by the NEMA, a Swiss-designed machine.