Everyone now knows that Ultra played a key role in winning the second World War for the Allies, but far less is known about the role of cryptanalysis in earlier conflicts. Mark Urban's fascinating study shows code-breaking in action during Wellington's Peninsular campaign against Napoleon's marshals.
Considerable strides were made in the art of ciphering during the Napoleonic wars, for France virtually had to start from scratch; the devising of codes, a quintessentially aristocratic activity, had perished along with the oligarchs during the Terror of 1792-94.
At the beginning of his wars, Napoleon was using a primitive cipher that could be cracked in two hours. After 1808, most messages sent en clair from Spain were intercepted by the ubiquitous and terrifying Spanish guerrillas so that there was a pressing necessity for the emperor to devise a new, impenetrable, code. This was the genesis of the grand chiffre or "Big Code" used by Napoleon to communicate with his brother Joseph, ruler of Spain.
Even when intercepted, the new cipher seemed at first to pose insurmountable problems to codebreakers. Before 1811, the French code consisted of numbers from one to 150. In order to destroy the well-known patterns that had made earlier, primitive ciphers easy to crack, the new system allocated nine different numbers to the letter "e" and the most common letters also had several variants.
The weak spot was that generals sending messages to Napoleon mixed code with "clear" to save time, which provided a context in which "educated guesses" at proper names could be made.
The deciphered proper names in turn could yield valuable clues to the meaning of certain numbers. Additionally, there was help from the captured messengers themselves. Fearing a horrible death at the hands of the bloodthirsty guerrillas and relieved to be handed over to the British, couriers would tell all they knew about matters at the court of "King Joseph", providing further valuable contextual clues.
The one-man Bletchley Park of the Napoleonic wars was Maj George Scovell, a career officer despised by Wellington for his "low birth". Wellington, who always prized breeding above brains, was prevailed on to tolerate Scovell only because he enjoyed the patronage of his secretary, the high-born Fitzroy Somerset, later to become notorious as the Lord Raglan of the Crimean War.
The year of decision for Napoleon, 1812, was also the annus mirabilis for Scovell, for he was given the task of cracking Napoleon's "invincible" Great Code. The new cipher used 1200 numbers, each randomly corresponding to a word, with another 250 numbers added as an afterthought. It also utilised "blank" numbers referring to nothing at all and included in the cipher simply to bamboozle would-be codebreakers. If all the messages transmitted from Spain had been in cipher, the code could have been cracked only by an Enigma-type computer, as in Ultra a hundred years later. But confidence bred complacency.
Thinking the code impenetrable, French generals wrote large chunks of their letters in clear, providing a context in which the ingenious Scovell could make chinks in the system. Because of laziness, staff officers often badly enciphered the "most secret" letters to Napoleon, using lots of plain text, enabling Scovell to pick out proper names. He was also able to correlate the most-used numbers with the commonest French words .
He soon twigged that all purely military words (such as "gunpowder") were clustered in the 1200-1450 range. With enough intercepts from the guerrillas and a few inspired guesses, he was soon able to start compiling his own glossary.
Urban demonstrates by detailed analyses of the ciphers and the conduct of the battles that Scovell's single-handed brilliance immeasurably helped Wellington win the battles of Fuentes d'Onoro, Salamanca and Vitoria. After Vitoria, the French realised their cipher had been broken and changed it, but by late 1813 codes were irrelevant as Napoleon was fighting for his life on French soil.
What of Scovell? Although knighted after Waterloo, he was reduced to penury as a half-pay officer though he survived to the age of 86 in 1861. He was effectively written out of history by Wellington because he had committed the "crime" of doing his job too well; if it became known that Wellington had been reading the enemy's secret mail, the legend of the peerless "Iron Duke" might have taken a hammering.
To make matters worse, Wellington later claimed that there had been no genius behind the cracking of Napoleon's grand chiffre and that he himself had played a major role in deciphering it. Perfidious Albion is never more so than when it betrays its own most loyal servants.
Frank McLynn is a biographer and historian. His latest book, Villa and Zapata, is published by Pimlico. His next book, a history of the US in the 1840s entitled Wagon's West, will be published next year by Jonathan Cape