Peter Twinn, who has died aged 88, was the first mathematician recruited as an Enigma cipher-breaker into the Government Code and Cipher School (GC&CS) before the Second World War; later he was credited with being the first British cryptographer to break an Enigma cipher, something that always embarrassed him and led him to dismiss its significance.
Recruited from Oxford in early 1939, Twinn worked at the GC&CS London headquarters, opposite St James's Park underground station, with Dilwyn "Dilly" Knox, the GC&CS Chief Cryptographer, who was attempting to break the Enigma ciphers.
He then moved to Bletchley Park, the codebreakers' wartime headquarters, working first with Knox and then Alan Turing tackling the German navy's Enigma ciphers.
In early 1942, he took over from Knox as head of the section breaking the Enigma ciphers used by the Abwehr, the German military intelligence service. As such, he played an important role in the Double Cross deception operation that was vital to the success of the D-Day landings.
Peter Frank George Twinn, the son of a senior General Post Office official, was born at Streatham on January 9 1916. He attended Manchester Grammar School and then Dulwich College, before going up to Brasenose College, Oxford, to read Mathematics.
He was in the middle of a postgraduate scholarship studying Physics when he saw an advertisement for a job with the government. "I was a bit unsettled," he remembered. "I'd finished my university degree and I didn't quite know what to do." The advertisement indicated that they were looking for mathematicians, but was unclear about what else was involved.
" They offered me this job at the princely salary of, I think, £275 a year," he said, "which sounded all right to me, and I was taken along on the first day to be introduced to Dilly Knox."
Twinn recalled that until that point GC&CS had been dominated by classicists.
"They regarded mathematicians as very strange beasts indeed, and required a little persuasion before they believed they could do anything practical or helpful at all."
Knox's approach to codebreaking and life in general was "mildly bizarre", Twinn later remembered: "He didn't believe in wasting too much time on training his assistant. He gave me a five-minute talk and told me to get on with it."
The Enigma machine had a keyboard into which the message was typed. Each letter then passed through a series of rotating wheels until the enciphered letter appeared on a "lampboard" above the machine. The British codebreakers had devised systems to break the cipher, but could not work out which letter on the keyboard was wired to which letter on the initial part of the encipherment mechanism.
Twinn said: "Our ordinary alphabet has them in a certain order, but the Germans aren't idiots. When they have the perfect safeguard to introduce to their machine, to jumble it all up would be the sensible thing."
Fortunately, in July 1939, Polish codebreakers, who had managed to break the Enigma ciphers but were now struggling, invited the British to a conference near Warsaw to discuss techniques that could be used to break the ciphers. They told Knox that the Germans had not, in fact, jumbled up the letters. They had wired A to A, B to B and so on, something the British had never thought possible.
"I know in retrospect it sounds daft," Twinn said. "It was such an obvious thing to do, rather a silly thing, that nobody, not Dilly Knox, not Alan Turing, ever thought it worthwhile trying."
When Knox came back, he went immediately on leave, so it fell to Twinn to try out the Polish technique. "The first thing I did when he was on leave was to see if it worked in the machine, and, of course, lo and behold, it did."
It was later pointed out to Twinn that this was the first time that any Wehrmacht Enigma cipher was broken in Britain, but he dismissed it as of no consequence: "It was a trifling exercise, but I repeat for the umpteenth time, no credit to me."
When the codebreakers moved to Bletchley Park, Twinn worked with Knox on Enigma research in the cottage next to the main house before helping Turing to set up the Hut 4 team, which broke the German naval Enigma.
In October 1941, Knox broke the Abwehr Enigma, allowing the codebreakers to ensure that the Germans believed the Double-Cross deception organised by MI5 and MI6. But he soon fell ill with cancer, and Twinn took charge of the Abwehr Enigma section in early 1942.
Its work was of particular importance during the Fortitude deception operation that helped to ensure the success of the D-Day landings.
After the war, Twinn worked in several government departments, including the Ministry for Technology in which, during the late 1960s, he was Director of Hovercraft under the then Labour Technology Minister, Tony Benn.
He subsequently became Secretary of the Royal Aircraft Establishment, Farnborough. During this period, he developed an interest in entomology, gaining a PhD in the subject from London University.
His doctorate was on the jumping mechanism of the click beetle, which he studied using the ultra-high-speed cameras available at Farnborough.
On one occasion, while attempting to collect click beetles at the edge of the Farnborough runway, he was arrested by an MoD police officer who was highly embarrassed to discover that his prisoner was in fact the RAE Secretary.
In 1999 Twinn published, with PT Harding, a study of the distribution of the longhorn beetle, A Provisional Atlas of the Longhorn Beetle (Coleoptera Cerambycidae) of Britain; it records the present and past distribution of 63 species and is to be found on the desks of many entomologists.
Twinn was a keen musician who played the viola and clarinet and wrote a number of pieces of music. It was this shared interest in music, and the concerts performed to entertain the other Bletchley Park codebreakers, which led to his meeting Rosamund Case, who worked in the registry and played the cello. They married in 1944.
Peter Twinn, who died on October 29, is survived by his wife Rosamund, and by a son and three daughters.