Alan Turing: Enigma and a conviction for being gay
How Alan Turing helped break Enigma, why the Bombe was a collective achievement, and how a consensual relationship led to his 1952 conviction.

Mục lục
The person reporting a burglary became the defendant
On 31 March 1952, in Knutsford, England, a mathematician appeared in court over a same-sex sexual relationship. The case began when someone burgled their home in Wilmslow. They reported it to the police, then acknowledged a relationship with a man named Arnold Murray during the investigation. The person who reported the crime became a defendant. This was Alan Turing, who had helped decipher German military messages during the Second World War[7].
Turing helped break Enigma not by guessing every possible password, but by using predictable fragments of messages to reject settings that contradicted themselves. They designed the principle of the Bombe, improved by Gordon Welchman and operated by a whole organization. That work did not protect Turing from laws criminalizing same-sex relationships. This article follows the letter-scrambling machine to the 1952 conviction, then to the apology and pardon decades later[2][8].
“Turing’s code” here means the story of Turing’s codebreaking. Enigma was the system Turing and colleagues attacked, not a cipher they invented. To understand their contribution, we need to look at a keyboard.
Why can two presses of A light up different letters?
You and a friend could hide a message by agreeing that A becomes D and B becomes E. Anyone with the substitution table can read it. But an outsider who collects enough messages can spot common letters and begin reconstructing the pattern.
Enigma made this harder. It had a keyboard, a lampboard, and scrambling wheels called rotors, like rotating disks routing electricity along different paths. When you pressed a key, the rotor mechanism stepped before the lamp lit up. Because the internal wiring had moved, consecutive presses of A could produce different letters[3].
Imagine a parking attendant changing the numbered bay chart after each customer. Knowing where the previous customer was sent would not tell you where the next one would go. Enigma still followed precise rules; the outsider simply did not know its current state.
Military machines also had a plugboard that swapped pairs of letters, like exchanging the labels on two key hooks before handing them to the parking attendant. Sender and receiver had to agree on the necessary settings: which rotors to use, their order, ring settings, letter pairs on the plugboard, and the starting position for the message[3].
With identical wiring, settings, and starting positions, the receiving machine turned the encrypted text back into readable text. Plaintext is the message before concealment, such as “meet at the café”; ciphertext is the sequence after concealment. The codebreaker’s task was to find the settings without seeing the sender’s instructions.
That is also why possessing a captured Enigma did not mean you could read every message. Knowing the model of a lock does not tell you which key opens today’s door.
Why did Britain fear those messages?
Britain is an island. During the war it needed more than a million tons of imported material every week to survive and keep fighting: food, fuel and weapons. Most of it crossed the Atlantic in merchant convoys, like a city that depends on a single road to bring in its vegetables from the wholesale market[10].
German submarines, the U-boats, waited on that road. Orders sending them toward the convoys travelled as radio messages enciphered on Enigma. Over the whole Battle of the Atlantic, about 3,500 Allied merchant ships were sunk; that figure covers the entire sea campaign, and not every loss came from being unable to read Enigma[10]. After the war, Churchill wrote that the only thing that really frightened him during the war was the U-boat peril[10].
The British could hear the radio signals. What they lacked was the meaning of those strings of letters.
Before Bletchley Park, there were codebreakers in Poland
The story did not begin with Turing sitting alone before a secret nobody had touched. In 1932, Marian Rejewski at the Polish Cipher Bureau made a breakthrough against military Enigma. Rejewski used mathematics describing rearrangements of elements, together with intelligence material supplied by the French. Jerzy Różycki and Henryk Zygalski continued developing codebreaking methods within the Polish team[5].
Such a rearrangement is a permutation, like changing the seating at a banquet without adding or removing guests. Instead of asking what each concealed letter means, we study the structure left by successive rearrangements. This viewpoint is related to Galois and the mathematics of symmetry, although the specific problems and methods differ.
In July 1939, before war broke out, the Polish side shared its methods and knowledge of Enigma with Britain and France. The Polish bomba device was part of that history. As communication procedures and Enigma configurations changed, the British needed a new method, rather than simply continuing to use the old device unchanged[5][2].
Turing began full-time work at Bletchley Park when war broke out in 1939. Their mathematical foundations predated that work: the paper on computability was completed in 1936, before wartime codebreaking[1]. It would therefore be misleading to say the first computer appeared simply because Turing needed to break Enigma. These were connected branches of work, not the same invention. That foundation, and the people who built the first working machines, are covered in Who is the father of the computer?.
A machine that never lets A become A
Enigma had a feature useful to its operators that also exposed a limitation. Current passed through the rotors, reached a reflector, and returned along a different path. This structure allowed the same settings to handle encryption and decryption. But a letter could never encrypt to itself[3].
You did not know which letter A would become. You did know that it could not become A. That was a small piece of information you could use immediately.
Suppose you suspected a message contained the German word WETTER, meaning weather. Write it on a strip of paper and slide it beneath the ciphertext. If an E in your guess sits directly beneath an E in the ciphertext, reject that alignment. There is no need to try any rotors or plugboard connections: the alignment already violates the machine’s rule[2][6].
A predicted plaintext fragment is called a crib, like guessing that a notice in an apartment building includes “Dear residents” even though the rest is covered. Standard message formats and communication habits could help codebreakers find cribs. But a guess could still contain the wrong words, have the wrong position, or both.
The no-self-encryption property provided an initial filter. The Bombe’s main task went further: checking whether relationships between multiple letters could all hold at once.
The Bombe asked whether there was a contradiction
Suppose you are arranging seating for a wedding. An initial assumption forces one guest to sit at table three. Following other conditions then forces the same guest to sit at table five in the same arrangement. You do not have to finish seating the whole room to know that something is wrong with your assumption.
The Bombe used a comparable principle of elimination. A crib aligned with ciphertext creates relationships between letters before and after their passage through the machine. Given a hypothetical rotor position, codebreakers could trace those relationships. If they forced the same wire connection to take two incompatible forms, that assumption was rejected[6].
Turing realized that this reasoning could be mechanized. The Bombe’s rotating drums simulated sets of rotors; electrical circuits connected them according to relationships derived from the crib. The machine worked through many states, rejecting those that produced contradictions. Gordon Welchman added a diagonal board, exploiting further the plugboard’s reciprocal letter swaps. This improvement reduced unhelpful stops[2].
This is constraint-based search: narrowing choices using conditions that must hold, like arranging wedding tables around the guests’ requirements. The comparison explains the idea; the Bombe was not seating software or a modern AI system.
And a stop did not mean the machine had read the message. Remaining candidates required further checking, completion of the settings, and a trial decryption. Some stops were simply incorrect candidates not eliminated by the circuit[6].
The first Bombe, named Victory, began working at Bletchley Park in March 1940. The National Museum of Computing records roughly 211 wartime Bombes, operated by personnel including members of the Women’s Royal Naval Service and the Royal Air Force. The British Tabulating Machine Company manufactured them[2]. Behind a name in a book were teams intercepting signals, finding cribs, designing machines, operating them, checking results, and analyzing the contents.
That success did not stand still. On 1 February 1942, the German navy brought a four-rotor version of Enigma into U-boat communications, and Bletchley Park lost the ability to read those messages for more than ten months. On 30 October 1942, sailors from the British destroyer HMS Petard recovered a weather short-signal codebook from the submarine U-559. Predictable fragments returned, and from December 1942 those messages were being read again[11]. When a lock gains one more pin, the whole team of locksmiths has to start probing again.
How much work can a few known letters remove?
We can run a small experiment without reconstructing the Bombe. Fix the rotors to I–II–III from left to right, the rings to AAA, reflector B, and no plugboard. Let only the three rotors’ starting positions vary. Under these restrictions, there are positions to try[3][4].
I created the plaintext WETTERBERICHT, meaning weather report, and encrypted it from position KAY. This is a self-created illustrative message, not a wartime document. The resulting ciphertext is SRJOHISCUSSFK. I then tried every starting position and counted how many matched the known number of initial plaintext letters.
| Initial plaintext letters known | Starting positions still compatible |
|---|---|
| 0 | 17,576 |
| 1 | 701 |
| 2 | 33 |
| 3 | 3 |
| 5 | 1 |
| 8 | 1 |
| 12 | 1 |

In this example, knowing the first five letters narrows the candidates to one starting position. That does not mean “five letters break every Enigma.” We supplied almost everything else in advance, including the absence of a plugboard. A different message or starting position can produce different candidate counts.
This test also does not simulate the Bombe algorithm. It directly tries starting positions on a restricted Enigma configuration. The figure shows why a little plaintext information can eliminate many hypotheses; the real Bombe had to address unknowns this experiment leaves out.
Why not try every possible plugboard?
Consider an alphabet of 26 letters and exactly ten plugboard cables. Each cable swaps a pair of letters. The number of arrangements is[6]:
This is a combinatorial count for a particular configuration choice, not the total number of keys for every Enigma model. Six unconnected letters remain unchanged at the plugboard, although they still pass through the rotors afterward.
We divide by because a cable connecting A–B is the same as B–A. We divide by because changing the order in which we list the ten cables creates no new wiring. Think of listing ten pairs of sandals: reversing how you write the left and right sandal, or changing the order of the listed pairs, does not produce different pairs.
Trying each plugboard separately would already be a large task. Turing’s approach used relationships between letters to reason about wire connections without independently listing every plugboard[6]. Speed came from removing unnecessary work, not merely spinning wheels faster.
That principle remains useful in computing. When software searches for a work schedule without overlapping shifts, a conflicting requirement can eliminate an entire branch of choices. Modern encryption uses structures different from Enigma; RSA and digital signatures explains one example. Enigma codebreaking should not be confused with how every modern encryption system can be attacked.
What did the 1952 conviction take away?
Return to the burglary in Wilmslow. Turing disclosed a relationship with Arnold Murray, who was then 19. Both were prosecuted under laws criminalizing sexual acts between men. On 31 March 1952, Turing pleaded guilty to the charge under the law then in force[7]. This was not abuse uncovered through a burglary investigation, but a consensual relationship treated as a crime.
Turing faced imprisonment or a year’s probation conditional on undergoing hormone treatment. They accepted the latter. The treatment used estrogen to suppress sexual function and is commonly described as “chemical castration.” It involved medication, not surgery[1][7].
The conviction also cost Turing their security clearance. The British government’s pardon announcement confirms that they could no longer work for GCHQ, the signals-intelligence organization that carried on wartime work[8].
But saying Turing was barred from all research afterward would also be incorrect. They continued working at the University of Manchester. In 1952, they published research on how chemical processes might generate biological shapes and patterns, while continuing other mathematical work[1]. Those papers show that research continued; they do not diminish the sentence’s effects on Turing’s body and freedom.
Wartime codebreaking remained subject to official secrecy. During the prosecution, Turing could not publicly reveal the full extent of the Bletchley Park work[1]. But the issue was not that they had failed to present enough achievements to deserve different treatment. People without scientific papers or military contributions did not deserve punishment for consensual relationships either.
What is known, and what should not be presented as fact?
Turing did not break Enigma alone. The Polish team laid foundations, Welchman improved the design, and engineers and operators turned the method into a functioning organization. Even that organization did not read every message: the museum notes that some keys were recovered within hours and some were never recovered[2]. There was no single switch-on moment that opened every wartime secret.
There is no certain measurement of exactly how many years Turing shortened the war. Codebreaking supplied valuable military intelligence. But to assign a precise number of years or lives saved to Turing alone, we would need to know how an alternative history without that work would have unfolded. A historical estimate should not be turned into a measured result.
Turing passed away on 7 June 1954, aged 41, from cyanide poisoning. The inquest concluded that they had taken their own life. Family members and some later authors questioned the circumstances[1][7]. We can report the official finding without claiming certain knowledge of every event or Turing’s final thoughts.
The story of a poisoned apple is often told as an established detail. But the apple found nearby was not tested[7]. It should not be treated as conclusive evidence, and gaps in the record should not become material for a sensational ending.
For another branch of Turing’s work, the Turing test explores the question of machines and thought. That is a separate story, not a byproduct of the Bombe.
Count the eliminated hypotheses yourself
The Python below uses the rotor wiring and reflector B published by Crypto Museum[4]. It includes the middle rotor’s double-stepping behavior[3], but fixes the rings to AAA, the rotor order to I–II–III, and omits the plugboard. Two initial assertions use short encryption examples to catch implementation errors; further checks confirm the message can be decrypted and no letter encrypts to itself.
You need matplotlib. Run the script from the directory in which you want the images/ folder; there is no randomness, so no seed is needed. It creates Figure 1 exactly.
from itertools import productfrom pathlib import Pathimport matplotlib.pyplot as plt
ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"# Rotors I, II, III left to right; rings AAA, no plugboard.W = ["EKMFLGDQVZNTOWYHXUSPAIBRCJ", "AJDKSIRUXBLHWTMCQGZNPYFVOE", "BDFHJLCPRTXVZNYEIWGAKMUSQO"]R = [[ABC.index(c) for c in w] for w in W]INV = [[r.index(i) for i in range(26)] for r in R]REF = [ABC.index(c) for c in "YRUHQSLDPXNGOKMIEBFZCWVJAT"]
def enigma(text, start): p = list(start) out = [] for c in text: # Double step: check notches E (rotor II), V (rotor III) before stepping. middle, right = p[1] == 4, p[2] == 21 p[0] = (p[0] + middle) % 26 p[1] = (p[1] + (middle or right)) % 26 p[2] = (p[2] + 1) % 26 x = ABC.index(c) for j in (2, 1, 0): x = (R[j][(x + p[j]) % 26] - p[j]) % 26 x = REF[x] for j in (0, 1, 2): x = (INV[j][(x + p[j]) % 26] - p[j]) % 26 out.append(ABC[x]) return "".join(out)
assert enigma("AAAAA", (0, 0, 0)) == "BDZGO"assert enigma("HELLOWORLD", (0, 0, 0)) == "ILBDAAMTAZ"plain = "WETTERBERICHT" # Illustrative plaintext, not a historical message.secret = tuple(ABC.index(c) for c in "KAY")cipher = enigma(plain, secret)assert enigma(cipher, secret) == plainassert all(a != b for a, b in zip(plain, cipher))lengths = [0, 1, 2, 3, 5, 8, 12]counts = [0] * len(lengths)for start in product(range(26), repeat=3): guess = enigma(plain[:max(lengths)], start) for i, n in enumerate(lengths): counts[i] += guess[:n] == cipher[:n]print("Plaintext:", plain, "| Ciphertext:", cipher)print("Known initial letters:", lengths)print("Compatible starting positions:", counts)
plt.rcParams.update({"font.family": "DejaVu Sans", "font.size": 12})fig, ax = plt.subplots(figsize=(10, 5.5), facecolor="#fcfcfb")ax.set_facecolor("#fcfcfb")ax.plot(lengths, counts, color="#2a78d6", lw=2, marker="o", ms=8)ax.set_yscale("log")ax.set_xticks(lengths)ax.set_ylim(0.65, 45000)for x, y in zip(lengths, counts): ax.annotate(str(y), (x, y), xytext=(0, 12), textcoords="offset points", ha="center", color="#0b0b0b")ax.set_xlabel("Known initial plaintext letters", color="#52514e")ax.set_ylabel("Compatible starting positions (log scale)", color="#52514e")ax.set_title("A plaintext fragment helps eliminate hypotheses", color="#0b0b0b", pad=24)ax.tick_params(colors="#52514e")ax.grid(axis="y", color="#e1e0d9", lw=0.7)ax.set_axisbelow(True)for side in ("top", "right"): ax.spines[side].set_visible(False)for side in ("left", "bottom"): ax.spines[side].set_color("#c3c2b7")fig.text(0.5, 0.015, "Enigma I–II–III · rings AAA · no plugboard · self-created message, not the Bombe", ha="center", color="#52514e", fontsize=10)fig.tight_layout(rect=(0, 0.055, 1, 1))folder = Path("images/turing-enigma-ban-an")folder.mkdir(parents=True, exist_ok=True)fig.savefig(folder / "loc-gia-thuyet-en.png", dpi=160)plt.close(fig)My output:
Plaintext: WETTERBERICHT | Ciphertext: SRJOHISCUSSFKKnown initial letters: [0, 1, 2, 3, 5, 8, 12]Compatible starting positions: [17576, 701, 33, 3, 1, 1, 1]You can replace KAY with another position and run it again. The candidate counts can change. The experiment does not establish a fixed reduction factor for every additional letter; it presents one specific, reproducible case.
Back to the Knutsford record
On 10 September 2009, Prime Minister Gordon Brown publicly apologized on behalf of the British government for Turing’s treatment. On 24 December 2013, Queen Elizabeth II granted a posthumous pardon[1][8]. The record that once held a conviction for a same-sex relationship now also contained an acknowledgment of its injustice.
The story did not end with someone whose name appears in mathematics books. In 2017, provisions commonly called “Turing’s law” extended pardons in England and Wales to many men convicted under old laws. Conditions applied: they did not excuse nonconsensual conduct or acts that remained crimes. For living applicants, the announcement at enactment tied pardons to the process of disregarding qualifying convictions[9].
At Bletchley Park, Turing helped turn a small piece of information into a way to eliminate many incorrect hypotheses. At Knutsford, what was treated as wrong was a consensual relationship. The conviction said nothing about the worth of that sexual orientation. It exposed the limits of the law that prosecuted Turing.
Free geometry illustrations for students and teachers: EyeViz.
Tài liệu tham khảo
- [1]J. J. O’Connor and E. F. Robertson. Alan Turing (1912–1954). MacTutor History of Mathematics, University of St Andrews.
- [2]The Turing-Welchman Bombe. The National Museum of Computing.
- [3]Enigma: working principle. Crypto Museum.
- [4]Enigma rotor wiring. Crypto Museum.
- [5]Cryptanalysis of the Enigma. Wikipedia; overview citing Polish and British codebreaking histories.
- [6]Bombe. Wikipedia; Principle of the bombe and Bombe menu sections.
- [7]Alan Turing. Wikipedia; Indecency conviction section and discussion of the circumstances in which Turing passed away.
- [8]Royal pardon for WW2 code-breaker Dr Alan Turing. UK Ministry of Justice, GOV.UK, 2013.
- [9]Thousands officially pardoned under ‘Turing’s Law’. UK Ministry of Justice, GOV.UK, 2017.
- [10]Battle of the Atlantic. Wikipedia; sections on British import needs, total losses and Churchill on the U-boat peril.
- [11]Enigma breaking: the naval Enigma story. uboat.net.


