- Overview
- About the Author
- Publication History and Background
- Bibliographic Information (English Original)
- Translations
- Contents (Spoilers)
- Chapter I: The Cipher of Mary Queen of Scots
- Chapter II: Le Chiffre Indéchiffrable
- Chapter III: The Mechanization of Secrecy
- Chapter IV: Cracking the Enigma
- Chapter V: The Language Barrier
- Chapter VI: Alice and Bob Go Public
- Chapter VII: Pretty Good Privacy
- Chapter VIII: A Quantum Leap into the Future
- Appendix: The Cipher Challenge
- Reception and Criticism
- Current Assessment (2020s)
- Influence
- Search Link
Overview
“The Code Book: The Science of Secrecy from Ancient Egypt to Quantum Cryptography” (1999) is a work of general-audience nonfiction by the British science writer Simon Singh. Through concrete events and personalities, it traces the history of the “arms race” between codemakers and codebreakers: from substitution ciphers in ancient Greece, to the cipher that sent Mary Queen of Scots to her execution, to the German Enigma machine and its decipherment during the Second World War, to the invention of public-key cryptography and the prospects for quantum cryptography. Like Singh’s first book, “Fermat’s Last Theorem” (1997), it became an international bestseller.

The book’s distinguishing feature is that it explains the mathematical principles of cryptography (frequency analysis, modular arithmetic, the difficulty of factoring large numbers, and so on) in terms accessible to readers without specialist knowledge, while at the same time presenting, as drama, how each technique bore on actual history: the execution of a queen, the outcome of wars, espionage during the Cold War, and the security of modern internet commerce.
The text has no footnotes; a chapter-by-chapter “Further Reading” guide is placed at the end of the book.
The book closes with a challenge to readers, “The Cipher Challenge”: a series of ten ciphers, with a prize of £10,000 for whoever solved them all.
More than a quarter of a century after its publication, in the mid-2020s, the book is still widely read as an introduction to the history of cryptography and remains generally well regarded, though this comes with reservations, namely experts’ criticisms of factual errors and the datedness of its predictions about quantum cryptography (details below).
About the Author
Simon Singh was born on 19 September 1964 in Wellington, Somerset, in southwestern England. His parents were Sikh immigrants from the Punjab region who had come to Britain from India in 1950. After attending Wellington School he studied physics at Imperial College London, then went on to postgraduate study at the University of Cambridge, where he did research at CERN (the European Organization for Nuclear Research) and earned a doctorate in particle physics.
In 1990 he joined the BBC’s science department and moved into television journalism. In 1996 he directed the BBC documentary “Fermat’s Last Theorem”, which dealt with the proof of that theorem and won several awards, including a British BAFTA award. The book written on the basis of that programme in 1997, his debut, became a worldwide bestseller, and it was on the strength of that success that he wrote his second book, “The Code Book” (1999).
Singh subsequently published “Big Bang: The Origin of the Universe” (2004, a history of Big Bang theory), “Trick or Treatment? Alternative Medicine on Trial” (2008, a critical examination of alternative medicine, co-written with Edzard Ernst), and “The Simpsons and Their Mathematical Secrets” (2013), among others.
Publication History and Background
The book was conceived on the back of the commercial success of Singh’s first book, “Fermat’s Last Theorem”. Where the earlier book concentrated on a single story, “the greatest problem in the history of mathematics”, this book widens its subject to a general history of cryptography, stringing together a number of episodes from antiquity to the present. At the time of publication, e-commerce on the internet was spreading rapidly, and public-key cryptography and RSA encryption were beginning to attract attention as technologies bearing directly on consumers’ everyday lives. In his preface, Singh states that the book has two aims: to trace the evolution of cryptography, and to show that cryptography is a subject of more contemporary relevance than ever.
It was published in Britain by Fourth Estate and in the United States by Doubleday, both in 1999. The subtitle differs between these editions and later reprints (see below).
The latter part of the book (Chapters VI to VIII) is based on direct interviews with the inventors of public-key cryptography, with Philip Zimmermann, the developer of PGP, and with researchers in quantum cryptography such as David Deutsch and Charles Bennett. The book describes how public-key cryptography had been conceived at the British Government Communications Headquarters (GCHQ) earlier than by researchers in the United States, but was kept unpublished because it was classified. This had come to light only in 1997, when GCHQ declassified the relevant documents, and was therefore recent news at the time.
The Cipher Challenge at the end of the book (ten cipher-breaking problems with a £10,000 prize) also functioned as a promotional device for the publisher, and, as described below, it became an important element in both the book’s reception and its influence.
Bibliographic Information (English Original)
- Title: “The Code Book: The Science of Secrecy from Ancient Egypt to Quantum Cryptography”
- Author: Simon Singh
- Publisher: Fourth Estate (UK) / Doubleday (US)
- Year of publication: 1999
The subtitle varies by edition. The British first edition (Fourth Estate) carries “The Code Book: The Science of Secrecy from Ancient Egypt to Quantum Cryptography”, while the American edition (Doubleday) used “The Code Book: The Evolution of Secrecy from Mary, Queen of Scots to Quantum Cryptography”. Some later reprints (Anchor Books, for example) adopt yet another subtitle, “The Code Book: The Secret History of Codes and Code-Breaking”.
Translations
According to the author’s official website and various bibliographic sources, the book has been translated and published in at least 20 countries, and is read across a wide range of regions, chiefly in European languages but also in Asia, the Middle East, and Latin America. Most of the major-language editions were published in a concentrated period from around 1999 to 2002, immediately after the original’s publication. The title is often freely rendered from language to language, for example as “Code Book”, “Secret Messages”, or “History of Cryptography”.
Contents (Spoilers)
Chapter I: The Cipher of Mary Queen of Scots
The chapter begins with the origins of the substitution cipher (the oldest cipher method, replacing each letter of the alphabet with a different letter one-to-one) and of frequency analysis, the technique that defeats it, which is said to have been devised in the ninth century by the Arab scholar Al-Kindi. Frequency analysis reached Renaissance Europe and effectively neutralized the security of simple substitution ciphers. The centrepiece of the chapter is the Babington Plot of 1586. The conspirators, who planned to assassinate Elizabeth I of England and to restore Mary to the throne, exchanged enciphered letters with the imprisoned Mary. Elizabeth’s cryptanalyst Thomas Phelippes deciphered them and established that Mary herself had included wording approving the plot. This decipherment served as the decisive evidence, and Mary was executed for treason in 1587. The theme that runs through the whole book, that those who overestimate the strength of their cipher are ruined by it, is already presented in the first chapter.
Chapter II: Le Chiffre Indéchiffrable
This chapter deals with the principle of the polyalphabetic cipher, the Vigenère cipher, devised to overcome the weakness of substitution ciphers, and with how it came to be called le chiffre indéchiffrable (the indecipherable cipher). It introduces the Great Cipher (Grand Chiffre) devised by the Rossignols, father and son, and used in practice under Louis XIV. The fact that later generations could not decipher it gave rise to the legend surrounding the identity of the Man in the Iron Mask. The chapter also touches on the reality of the “black chambers” (specialist bureaus that intercepted and deciphered diplomatic correspondence) established in the European states of the eighteenth century. Its climax is the story of Charles Babbage, who in the nineteenth century privately discovered a method of breaking the Vigenère cipher but did not publish it, so that the credit was later attributed to the Prussian army officer Friedrich Kasiski, who published the method in 1863. The chapter ends with the Beale ciphers (an enciphered text said to record the location of buried treasure), which remain unsolved among cipher enthusiasts to this day.
Chapter III: The Mechanization of Secrecy
The chapter describes how, in the early twentieth century, mechanical cipher devices were sought in order to overcome the limits of enciphering and deciphering by hand. After cases of failed cipher practice in the First World War (above all the Zimmermann Telegram, which was deciphered by the British and helped bring the United States into the war), the technology developed from cipher disks to rotor machines, and the account culminates in the invention of the Enigma by the German engineer Arthur Scherbius in 1918.
Chapter IV: Cracking the Enigma
This is one of the most dramatically told chapters of the book. It gives a detailed account of the work of Marian Rejewski and his colleagues at the Polish Cipher Bureau (Biuro Szyfrów), who found the theoretical weaknesses of the Enigma in the early 1930s, and of how they combined the acquisition of German codebooks (including information supplied by the spy Hans-Thilo Schmidt, who worked for the French) with mathematical methods (an analysis focusing on the cycle structure of permutations) to reconstruct the Enigma’s keys. Just before the outbreak of the Second World War, Poland handed its results over to Britain and France. At Bletchley Park, Alan Turing and others developed them further, designing an electromechanical decipherment device known as the Bombe and establishing a system (Ultra) that allowed German cipher traffic to be read almost routinely. The chapter stresses that this operation was conducted under strict secrecy and was not made public for a long time after the war, and that, because of this secrecy, the contributions of many of those involved went unrecognized for a long period.
Chapter V: The Language Barrier
Standing apart from codebreaking proper, the chapter treats the history of the decipherment of lost ancient scripts. It centres on Jean-François Champollion’s decipherment of Egyptian hieroglyphs (achieved in 1822 with the trilingual inscription on the Rosetta Stone as a clue) and on the decipherment of Linear B (a syllabic script used in ancient Crete and Greece) by the architect Michael Ventris in the twentieth century, including the trial and error before Ventris established that the language was a dialect of Greek.
Chapter VI: Alice and Bob Go Public
The chapter deals with the invention of public-key cryptography, the turning point of modern cryptography. In the 1970s Whitfield Diffie, Martin Hellman, and Ralph Merkle arrived at the concept of the one-way function, which makes it possible to communicate in cipher without first sharing a key securely, and Ronald Rivest, Adi Shamir, and Leonard Adleman then devised RSA encryption, which exploits the difficulty of factoring large numbers. The chapter then introduces the fact that essentially the same idea had been discovered several years earlier at GCHQ in Britain by James Ellis, Clifford Cocks, and Malcolm Williamson, but as a state secret; it became public only when GCHQ declassified it in 1997.
Chapter VII: Pretty Good Privacy
This is the story of Philip Zimmermann, the programmer who developed the encryption software PGP (Pretty Good Privacy) so that ordinary citizens could use strong cryptography against government interception of their communications. By releasing PGP free of charge on the internet, Zimmermann became the subject of a federal grand jury investigation on suspicion of violating US export controls (regulations treating strong cryptographic technology as munitions), but in the end no charges were filed. The tension between the right of individuals to privacy and the state’s need to intercept communications for investigation and security is presented as the chapter’s theme.
Chapter VIII: A Quantum Leap into the Future
The final chapter explains the prospect that, if quantum computers become practical, factoring the large composite numbers on which the security of RSA rests would become feasible in realistic time, so that current public-key cryptography could in principle be neutralized. It also explains quantum cryptography (quantum key distribution), which is being researched as a solution. The principle is that, because photon polarization angles are used and any attempt by an eavesdropper to read the communication is itself detectable under quantum mechanics (observation alters the state), key distribution that is in theory impossible to eavesdrop on becomes possible.
Appendix: The Cipher Challenge
At the end of the book was appended a series of ten ciphers, rising in difficulty from easy to hard, with a prize of £10,000 for the first person (or team) to solve them all. On 7 October 2000 a team of five from Sweden (Fredrik Almgren, Gunnar Andersson, Torbjörn Granlund, Lars Ivansson, and Staffan Ulfberg) solved them and won the prize.
Reception and Criticism
On publication, “The Code Book” became an international bestseller and was highly praised by both general readers and reviewers. Many general reviews commend Singh’s skill in conveying the mathematical core of cryptography (frequency analysis, modular arithmetic, the difficulty of factoring large numbers, the measurement problem in quantum mechanics, and so on) to readers without specialist knowledge, and the skill of his storytelling in bringing historical figures to life.
On the other hand, experts have criticized the book for its many factual errors. The most detailed criticism is the review by Jim Reeds, a cryptography researcher at AT&T Labs, in the March 2000 issue of “Notices of the American Mathematical Society”. Reeds observes that, in numerous places, Singh writes without adequately understanding the technical vocabulary of his historical sources, and gives examples of errors such as the following.
- The book describes the rotors (cipher wheels) of the Enigma as made of rubber. In fact they were made of aluminium, brass, and Bakelite, and Singh probably confused this with a description of a different cipher machine in David Kahn’s work.
- The book states that Turing, in his 1937 paper, called his hypothetical computing mechanism a “universal Turing machine”. The terms Turing himself used were “computing machine” and “universal machine”; the name “Turing machine” was coined later.
- The book states that the British cryptanalytic agency, the Government Code and Cypher School (GC&CS), was dissolved after the war and replaced by Government Communications Headquarters (GCHQ). In fact only the name was changed, in 1942, and the organization is continuous.
- The book states that the decipherment of the Japanese Navy’s “Purple” cipher led to victory at the Battle of Midway and to the assassination of Admiral Isoroku Yamamoto. The cipher actually involved was JN-25; Purple was a separate system used mainly for diplomatic traffic.
- The permutation example used in explaining Rejewski’s mathematical decipherment of the Enigma has a cycle structure that is impossible given the actual structure of the Enigma, and is therefore an unrealistic example.
Reeds also notes that Whitfield Diffie, one of the parties concerned in the account of the invention of public-key cryptography, expressed dissatisfaction in the British review paper “Times Higher Education Supplement” (10 September 1999 issue) that what he had told Singh had not been accurately conveyed.
These criticisms should be understood with the limitations of the book as a work of popular science in mind. It is a work for general readers, without footnotes or rigorous source citations, and Reeds’s review also raises a question that concerns popular writing on the history of science in general: how much rigour can be demanded of a book of that kind.
Current Assessment (2020s)
The following points should be added from a present-day perspective.
- The account of quantum cryptography in the final chapter was written as a prospect reflecting the state of research in the late 1990s, and over the following quarter-century the situation developed somewhat differently from the book’s outlook. The main response adopted by the cryptographic community to the “threat of quantum computers” against current public-key cryptography, such as RSA and elliptic-curve cryptography, was not quantum key distribution using photon polarization (the technology the book chiefly introduces), but new mathematical algorithms that can be computed on ordinary computers and are believed to withstand attack by quantum computers (post-quantum cryptography). In August 2024 the US National Institute of Standards and Technology (NIST) formally announced three post-quantum cryptography standards, ML-KEM (FIPS 203), ML-DSA (FIPS 204), and SLH-DSA (FIPS 205), and this is now the main direction of response. Quantum key distribution itself has also seen some practical progress, for example the demonstration by China’s quantum communications satellite Micius (2017), but at the time of the book’s publication it was presented as a technology still at a purely theoretical and laboratory stage.
- There were also major developments after the book’s publication concerning the tragic last years of Alan Turing described in Chapter IV (his conviction in 1952 for homosexual acts, his subsequent treatment, and his death in 1954). In 2009 the British government issued an official apology in the name of the then prime minister Gordon Brown, and in 2013 Queen Elizabeth II granted a posthumous royal pardon. In 2017 a pardon law (popularly known as “Turing’s Law”) was enacted covering other men convicted of similar offences.
- The 512-bit RSA key used in the Cipher Challenge required considerable computing resources to break in 2000, but as computing power has improved, RSA with a 512-bit key now offers practically no protection. The 512-bit key length had already been shown to be unsafe in August 1999, shortly before the book’s publication, when RSA-155, a 155-digit number from the RSA Challenge factoring list that represents a 512-bit RSA modulus, was factored. Even so, it was widely used at the time, particularly outside the United States, where US export restrictions on strong cryptography were a factor, for the protection of electronic commerce.
Despite the errors and outdated information noted above, the book has retained, more than a quarter-century after publication, a generally standard position as a general-audience introduction to the history of cryptography. On the book-review site Goodreads it maintains a high rating of 4.3 out of 5 from over 28,000 ratings, and it continues to appear in lists such as “recommended books on cryptography”.
Influence
One of the most concrete effects of the book is the National Cipher Challenge, a competition for British secondary-school students begun in 2002 by the mathematics department of the University of Southampton, inspired by the Cipher Challenge at the end of the book. The programme has been supported by bodies including the EPSRC (Engineering and Physical Sciences Research Council) and Bletchley Park, and Singh himself remained involved as a sponsor for many years.
In a broader context, the book became a reference point for later books of the same kind (general-audience nonfiction on the history of cryptography and information security), as a representative popular science book that opened the specialist subject of cryptography and information security to general readers. By introducing to general readers, at the earliest opportunity, the then-latest information about the declassification of GCHQ’s earlier discovery of public-key cryptography, it also played a part in making widely known the question of the relationship between state secrecy and academic priority in cryptographic research.
Furthermore, the public debates on cryptography and privacy in which Singh himself later took part (policy disputes over the regulation of strong cryptography and the introduction of backdoors, for example) are an extension of the confrontation between “privacy and national security” treated in Chapter VII of the book, and the book is often cited as an introductory text in the subsequent cryptography policy debates.
