In 1941 Hilton was a young Oxford undergraduate when he was recruited to Bletchley to work in a section known as the Testery (after its head, a linguist called Major Ralph Tester). His colleagues there were Alan Turing; Roy Jenkins (the future Labour Chancellor of the Exchequer); Peter Benenson (who later founded Amnesty International); and Hugh Alexander, the British chess champion. Also there was Donald Michie, a young Oxford classics scholar who became a professor of artificial intelligence and whose various claims to fame included the post of curator of the *Balliol Book of Bawdy Verse*.

Hilton initially worked with Turing on breaking German naval codes produced by Enigma machines, and concentrated on top secret Offizier messages (for officers' eyes only). His extraordinary powers of visualisation meant that in his mind's eye he could unpick streams of characters from two separate teleprinters -- a faculty that was to prove invaluable in the feverish mental chess game with the enemy.

Success rates were high and decryption was accomplished at remarkable speed. At the end of 1942 he was moved to work with a group of some 30 mathematicians on the yet more sophisticated code which the Germans had started using in 1940 to encrypt top-secret messages -- mainly between Hitler and his generals.

Known by the irreverent nickname "Fish", these messages to and from the German High Command were produced by a much larger and more complex machine than Enigma.

Many years after the war, this was revealed to be a Lorenz SZ40 encoder, but at the time staff at Bletchley Park called it "Tunny". Hilton played one of the most important roles in the unit's cryptology department, monitoring any changes in "Tunny's" output and eventually becoming chief cryptanalyst on the "Tunny" project.

Codebreakers managed to work out how "Tunny" was constructed as a consequence of an operational slip by a German cipher operator in 1941. It was a crucial error. As a result, Bletchley Park cryptanalysts led by Hilton were able to work out the basic design and build an emulator they called Heath Robinson, after the cartoonist famous for drawing crackpot inventions.

But this proved far too slow at processing the data, and eventually a bigger and better version was developed. Colossus, as it was known, was the world's first programmable computer, weighed a ton, and could crack a Lorenz-encrypted message in hours rather than days. Eventually, 10 were built.

Occasionally German encoders failed to change the settings on their machines and two messages would be sent under the same "key" -- a vital lapse in security that was known at Bletchley as a "depth". From this, decoders were able to produce a stream of "clear" (or deciphered text), that was a jumble of the two messages mixed together.

Using his startling ability to visualise two teleprinter streams, Hilton spent countless hours resolving the merged "depths" into individual messages in "clear", deriving "enormous excitement" in cracking what appeared at first to be "utter gibberish".

"For me," he remembered, "the real excitement was this business of getting two texts out of one sequence of gibberish. I never met anything quite so exciting, especially since you knew that these were vital messages."

After the war Hilton was indignant about the treatment meted out to Turing -- "an authentic genius" -- who committed suicide in 1954 after his homosexuality was exposed. Hilton (who renewed his acquaintance with Turing postwar at the Mathematics faculty at Manchester University) never guessed Turing's sexual orientation in all the time they worked together, and neither did the Bletchley Park authorities. "Otherwise," as Hilton's fellow codebreaker Jack Good noted, Turing may have been driven to kill himself earlier and "we might have lost the war".

Peter John Hilton was born on April 7 1923 in Brondesbury, north London, the son of a GP with a practice in Peckham. From St Paul's School he won a scholarship to Queen's College, Oxford, where he read Mathematics and, like all undergraduates at the time, underwent military training, in his case for the Royal Artillery.

In 1941, when he was 18, Hilton was recruited by the Foreign Office on the strength of his mathematical ability and knowledge of German (a language he had taught himself in a year), for what was then unspecified secret work. Hilton thought his German was probably not up to scratch. "But I was the only person who turned up at the interview," he recalled, "and they jumped at me and said: 'Yes, you must come'."

In his off-duty hours, Hilton earned a reputation as a convivial companion. He was regular in the bar of the Bletchley pub that was subsequently renamed The Enigma, and often attended dances at nearby Woburn Abbey, where Wrens were billeted. He also became a renowned exponent both of bawdy songs (notably *My Brother Sylvest*) and dirty jokes.

Postwar, he returned to Oxford to complete his degree and, in 1948, was appointed to an assistant lectureship at Manchester University. After a spell as a lecturer at Cambridge, he returned to Manchester in 1956 before moving to Birmingham University two years later as the Mason Professor of Pure Mathematics, a chair he held for four years.

He confessed that it was a long time before he found work that compared with the heady excitement of his days at Bletchley Park.

As an academic, Hilton (with other prominent mathematicians) created a new discipline in mathematics, homology theory, which despite its abstract-sounding name has practical applications, among them the classification of complicated surfaces in space. He also made significant contributions to other areas of mathematics: combinatorial geometry, combinatorics and number theory.

Homology theory has influenced not only algebra but also geometry. Hilton also made important contributions to the field of algebraic topology, a branch of mathematics which uses tools from abstract algebra to study topological spaces -- mathematical structures that allow the formal definition of concepts such as convergence, connectedness and continuity. When, after the war, Hilton asked his old Bletchley Park colleague, Professor Henry Whitehead: "What is algebraic topology, Henry?", Whitehead replied: "Don't worry, Peter. You'll love it!"

In 1962 Hilton left Britain for the United States, and was Professor of Mathematics at Cornell University until 1971, when he took a post at the University of Washington. He held the Louis D Beaumont chair at Case Western Reserve University for several years and in 1982 was appointed Distinguished Professor at the State University of New York, Binghamton. He retired in 1995.

In the course of his career, Hilton published books on mathematics and mathematics education, as well as hundreds of articles in learned journals. He lectured at conferences all over the world well into his eighties.

During his time at Bletchley Park, Hilton was given every fourth week off to hone his cryptanalytical skills; by way of a change of mental gear, he helped Turing solve chess problems, puffed on his pipe, and once spent a sleepless night composing one of the world's longest palindromes: DOC, NOTE: I DISSENT. A FAST NEVER PREVENTS A FATNESS. I DIET ON COD.

Peter Hilton married, in 1949, the actress Margaret Mostyn, who survives him with their two sons.