During the Second World War, Turing worked at Bletchley Park, Britain's codebreaking center, where he led the team responsible for breaking the German navy's Enigma cipher, building on foundational work done before the war by Polish cryptologists Marian Rejewski, Jerzy Rozycki, and Henryk Zygalski. Turing designed the Bombe, an electromechanical machine that could search through the vast number of possible Enigma settings far faster than any human, and the intelligence it produced, codenamed Ultra, is widely credited by historians with shortening the war, though by precisely how much remains genuinely debated.
Turing's postwar career continued at the National Physical Laboratory and the University of Manchester, where he worked on some of the earliest stored-program computers and wrote a landmark 1950 paper proposing what became known as the Turing test, a practical way to ask whether a machine could be said to think. In 1952 he reported a burglary to the police and, in the course of the investigation, disclosed a sexual relationship with another man, homosexual acts were then a criminal offense in Britain, and Turing was convicted of gross indecency. Offered a choice between prison and a course of hormone treatment intended to suppress his libido, he accepted the treatment, which was administered for a year and had significant physical side effects.
Turing died in June 1954 of cyanide poisoning, an inquest at the time ruled it suicide, and most historians accept that verdict, though a minority have argued the death could have been accidental, from cyanide fumes produced by an experiment he was known to be running at home. The British government issued a formal apology for his treatment in 2009 and a royal pardon in 2013, in 2017 a law informally called the Alan Turing law posthumously pardoned thousands of other men convicted under the same since-repealed statute.