When I was an undergraduate at Harvard, an astronomer from Berkeley came over to the physics building to give a talk. His name was Cliff Stoll, and he didn't give a talk about astronomy. He gave a talk about accounting.

I remember the details less than Stoll's frizzy Eurofro and his jumping around the front of the lecture hall as if he were on something Miley Cyrus might like to try. For some reason, this astronomer worked on computers, and one day, he noticed a 75-cent accounting error, a phone bill discrepancy or something like that. Normally, someone who is only interested in estimating the age of the universe up to a few billion years ought not to be so concerned with a 75-cent error, but Stoll did care.

It led him to a German KGB spy ring paid in cocaine. But that's his saga. My point is that once Stoll figured out that spies were slipping into his computer system, he laid a trap: a file called "Star Wars", referring to the Strategic Defence Initiative.

The "Star Wars" file was big but it was fake. It contained nothing valuable. Maybe a recipe for really excellent-tasting cherry bakewells or something like that, but that's all. It was sweet enough to entice the spies, and large enough to keep them on the system long enough for Stoll to trace them. Gotcha.

A propos, what's surprising about the US state department/WikiLeaks scandal is that there is a scandal. As a friend reminded me, these days, it's really quite easy to make sure no one can read your messages, unless you want them to.

The science of cryptography has been around for ages. One of the simplest codes was used by Caesar. He would send secrets simply by shifting the letters of the message a few notches down the alphabet: "Mw xlex e hekkiv sv evi csy nywx lettc xs wii qi?" (Ouch!) I should point out that this kind of code is easy to break, since an interceptor can do some statistical analysis and figure out how many letters you have shifted down the alphabet by comparing the most common letter in your message with the letters that appear most frequently in your language. (I should perhaps further point out that this code is only easy to break if you're not a barbarian Gaul. They did not have good schools.)

In the second world war, the Germans developed a device that, they believed, produced an unbreakable code: the Enigma machine. It resembled a typewriter, with a series of gears and wheels that produced a different letter each time you typed the same key.

And if, by chance, the Allies figured out this more complicated version of the Caesar shift, the next day the Germans could reset the keys and the Allies would have to figure the code out again, starting from scratch.

The problem was that Germans may be efficient when it comes to tram schedules, but not so much when it comes to resetting Enigma machines. The Allies, led by the likes of Cambridge mathematician Alan Turing, and with the help of Polish codebreakers, used high-speed, electronic computers that could work just fast enough to figure out Enigma's "unbreakable" code.

It would seem there is no unbreakable code. For every scheme, you just build a faster computer to crack it, right?

Not necessarily. It's possible that there may be a theoretical limit to how quickly you can perform certain tasks called "NP-complete problems" – the "N" standing for "non-deterministic Turing machine" – that you would need to be able to perform quickly if you wanted to break codes in less time than it would take monkeys to type Hamlet. If so, and we think it is so, all you'd need to do to keep third parties from reading your messages is to take two really, really big prime numbers – say, with 200 digits each – and multiply them together. (It's OK to use calculators.)

The method is called "public key cryptography". It's really all the rage, and I'd be a bit surprised if US Secretary of State Hillary Clinton, whose cables have been leaking out, didn't know about it. The people up the road at the NSA certainly do.

The National Security Agency is a riddle wrapped in a mystery inside a code. It dwarfs the CIA. And, most disturbing of all, it is the world's largest employer of mathematicians. And they're really, really good at multiplying.

Roughly, the idea behind public key cryptography is that you have one prime; the intended recipient has the other; and the message is transmitted openly using the product of the numbers (or perhaps using an exponential version of the Caesar shift). Anyone can pluck the message out of the air, but factoring a giant number may be like one of those NP-complete problems. Even Turing machines can't do it quickly, we think.

So, when it comes to WikiLeaks obtaining US diplomatic cables, either no one at the US state department had ever heard of cryptography, or they were too lazy to care, or –

Gotcha.