Ian Fleming, the author of the James Bond books, was the liaison between naval intelligence and the Government Code and Cypher School (GC&CS) during the Second World War. The GC&CS was a secret organisation, and if the Germans had known what it could do and where it was located they’d have bombed the living daylights out of the place. The employees, if that’s the right term, chess masters, mathematicians, classicists, crossword puzzle enthusiasts and other assorted oddballs, worked in Nissen huts, after overflowing the original mansion. They were spread around a large estate and didn’t necessarily know one another, so at a reunion 46 years after the war they were surprised to see who else had been working there. No one spoke about it to outsiders, not a word, not a peep, and when one woman found out that her husband had an invitation to the reunion she asked how on earth he’d got it. She’d worked there but never told him — he likewise.

Now we all know. It was at Bletchley Park — just outside Milton Keynes, Buckinghamshire — in a place one can visit and be taken round to see the captured Enigma machines with their plug boards and three coding wheels, the naval and *Abwehr* ones with four wheels and the Lorenz machine with its 12 wheels, used by the German High Command. A method for cracking the Enigma code was originally achieved by the Poles, but figuring out the latest settings was an ongoing process, using huts full of brain-power. The standard Enigma used by the German army and air force was one thing, but getting hold of the settings for a naval machine was an important priority and Fleming had an idea. Crash a captured German aeroplane into the English Channel with British Special Forces on board. When picked up by the German navy they would overpower the crew and capture the week’s settings. It never happened, but something else did. In late 1942, when food supplies in Britain were down to about six weeks’ holdings, three men — one a mere 16-year-old — entered a U-boat in the North Atlantic and brought out the monthly key settings for the *Kriegsmarine* Enigma. The 16-year-old survived; the other two died in the operation.

Hut Eight, where the mathematician Alan Turing worked, dealt with German naval codes. This brilliantly original thinker designed an electro-mechanical decipherment machine to replace the original Polish one. His work helped reduce the losses in the Atlantic from 500,000 to 50,000 tons a month. Some mathematicians have been faintly asexual people working in the quiet seclusion of English vicarages and Oxbridge colleges, but Turing was a man of physical and sexual energy who occasionally ran the 40 miles to London to attend important meetings. After the war, he was awarded an OBE, but later was prosecuted for his sexuality — he was gay. In 1954, aged 41, he committed suicide, and only in September last year did the then Prime Minister apologise for his prosecution, describing his treatment as “appalling”. It was.

While German naval codes were a tough nut to crack, the German high command ciphers (called Tunny) on the 12-wheel Lorenz machine were all but impossible, particularly since Bletchley did not have a captured Lorenz machine — they acquired one only after the war. But there was a lucky break on August 30, 1941. A German operator in Athens transmitted a 4,500-character message to Vienna. It wasn’t received correctly, so the operator requested retransmission — but without encrypting the request. This alerted the codebreakers and when Athens sent the message a second time, using abbreviations but the same settings, they betrayed invaluable information. A mathematician named Bill Tutte then reverse-engineered the Lorenz machine, and the Post Office Research Centre in Dollis Hill, north London, started to design a huge computer called Colossus to decipher messages from the German high command. This intellectual feat dwarfed Enigma, but it was a race against time. By June 1 1944, Colossus Mark 2 was in operation at Bletchley, just in time for the Normandy D-Day landings. Cracking the high command ciphers showed that Hitler had been convincingly misled about the location of the landings and German troops were being kept in the wrong position.

In the early 1950s, GC&CS transferred to GCHQ at Cheltenham and the Nissen huts of Bletchley have now morphed into a vast modern building called the doughnut. There in 1970 James Ellis showed there must be ciphers where full knowledge of the encryption method would still leave you at a loss to do the decryption — it’s called public key cryptography. In 1973, Clifford Cocks, also at GCHQ, was told about Ellis’s idea and came back half an hour later with a mathematical method of doing it. This was all entirely secret, of course, but in 1978 three people — Ron Rivest, Adi Shamir and Leonard Adleman — rediscovered it, and it’s now called the RSA algorithm. Here’s the idea.

You take a huge number *N — *600 digits, say — bigger by far than the number of particles in the universe. Transfer your secret message into a string of numbers and split it into pieces, each less than *N*. Encrypt the message by doing a sequence of simple mathematical operations but at each stage take only the remainder after dividing by *N*. The enemy can intercept the encrypted message, know the big number *N* along with the exact sequence of operations, but still be at a loss. Doing the decryption is equivalent to factorising the big number *N*, but even with the best methods available that would take more time than the age of the universe. Creating the big number *N* is easy: you take the product of two 300-digit prime numbers. You — or your computer — knows the factorisation, but no one else does.

Little surprise then that GCHQ uses mathematicians, including academics from the universities, though they can’t talk about what they do and aren’t even supposed to think about it when they’re back home. Britain is good at secrecy, as Bletchley’s history shows. But I have a nagging doubt. It’s all very well to have a spankingly modern building and use the latest mathematics, but there are some odd people in the world. Hackers can access Pentagon secrets from attics in North London, and in his book *The Man who Mistook his Wife for a Hat*, Oliver Sacks describes two autistic, computationally challenged brothers who could turn out huge prime numbers at the drop of a hat. And then there are quantum computers, which in principle could quickly do the factorisation. But no one has built one of any size — or have they?

I hope GCHQ still has a few Nissen huts, with eccentric people working in them, though we probably won’t read about them for another 50 years.

The ravenous longing for the infinite possibilities of “otherwhere”

"Yuletide revels were designed to see you through the dark days — and how dark they seem today"