# Book cipher

A book cipher is a cipher in which each word or letter in the plaintext of a message is replaced by some code that locates it in another text, the key.
A simple version of such a cipher would use a specific book as the key, and would replace each word of the plaintext by a number that gives the position where that word occurs in that book. For example, if the chosen key is H. G. Wells's novel The War of the Worlds, the plaintext "all plans failed, coming back tomorrow" could be encoded as "335 219 881, 5600 853 9315" — since the 335th word of the novel is "all", the 219th is "plans", etc. This method requires that the sender and receiver use exactly the same edition of the key book.
This simple version fails if the message uses a word that does not appear in the text. A variant that avoids this problem works with individual letters rather than words. Namely each letter of the plaintext message would be replaced by a number that specifies where that letter occurs in the key book. For example, using the same War of the Worlds book as the key, the message "no ammo" could be encoded as "12 10 / 50 31 59 34" since the words with those positions in the novel are "nineteenth", "of", "almost", "mortal", "might", and "own". This method was used in the second Beale cipher. This variant is more properly called a substitution cipher, specifically a homophonic one.
Both methods, as described, are quite laborious. Therefore, in practice, the key has usually been a codebook created for the purpose: a simple dictionary-like listing of all the words that might be needed to form a message, each with the respective code number(s). This version is called a code, and was extensively used from the 15th century up to World War II.

## Choosing the key

The main strength of a book cipher is the key. The sender and receiver of encoded messages can agree to use any book or other publication available to both of them as the key to their cipher. Someone intercepting the message and attempting to decode it, unless they are a skilled cryptographer (see Security below), must somehow identify the key from a huge number of possibilities available. In the context of espionage, a book cipher has a considerable advantage for a spy in enemy territory. A conventional codebook, if discovered by the local authorities, instantly incriminates the holder as a spy and gives the authorities the chance of deciphering the code and sending false messages impersonating the agent. On the other hand, a book, if chosen carefully to fit with the spy's cover story, would seem entirely innocuous. The drawback to a book cipher is that both parties have to possess an identical copy of the key. The book must not be of the sort that would look out of place in the possession of those using it, and it must be of a type likely to contain any words required. Thus, a spy wishing to send information about troop movements and numbers of armaments would be unlikely to find a cookbook or romance novel useful keys.

## Using widely available publications
### Dictionary

Another approach is to use a dictionary as the codebook. This guarantees that nearly all words will be found, and also makes it much easier to find a word when encoding. This approach was used by George Scovell for the Duke of Wellington's army in some campaigns of the Peninsular War. In Scovell's method, a codeword would consist of a number (indicating the page of the dictionary), a letter (indicating the column on the page), and finally a number indicating which entry of the column was meant. However, this approach also has a disadvantage: because entries are arranged in alphabetical order, so are the code numbers. This can give strong hints to the cryptanalyst unless the message is superenciphered. The wide distribution and availability of dictionaries also present a problem; it is likely that anyone trying to break such a code is also in possession of the dictionary which can be used to read the message.

### Bible cipher

The Bible is a widely available book that is almost always printed with chapter and verse markings making it easy to find a specific string of text within it, making it particularly useful for this purpose; the widespread availability of concordances can ease the encoding process as well.

## Security

Essentially, the code version of a "book cipher" is just like any other code, but one in which the trouble of preparing and distributing the codebook has been eliminated by using an existing text. However this means, as well as being attacked by all the usual means employed against other codes or ciphers, partial solutions may help the cryptanalyst to guess other codewords, or even to break the code completely by identifying the key text. This is, however, not the only way a book cipher may be broken. It is still susceptible to other methods of cryptanalysis, and as such is quite easily broken, even without sophisticated means, without the cryptanalyst having any idea to what book the cipher is keyed.

## Examples

* A famous use of a book cipher is in the Beale ciphers, of which Document No. 2 uses (a variant printing of) the United States Declaration of Independence as the key text.
* In the American Revolution, Benedict Arnold used a book cipher, sometimes known as the Arnold Cipher, which used Sir William Blackstone's Commentaries on the Laws of England as a key text.
* Book ciphers have consistently been used throughout the Cicada 3301 mystery.

### In fiction

* In Colony, a television series, the resistance movement uses a book cipher to communicate between members of the cells.
* In the novel Monsieur Lecoq, published in 1868, Monsieur Lecoq finds that a prisoner is communicating with his confederate using a double book cipher. Since the prisoner has only one book, The songs of Béranger, the solution is easily discovered.
* In The Valley of Fear, Sherlock Holmes decrypts a message enciphered with a book cipher by deducing which book had been used as a key text.
* The name of Ken Follett's World War II thriller The Key to Rebecca refers to a German spy in Cairo using Daphne du Maurier's novel Rebecca as the basis of a code.
* In A Presumption of Death, Lord Peter Wimsey, on assignment for British Intelligence in World War II Nazi-occupied Europe, uses a code based on the works of John Donne. The Germans break the code, coming near to catching Wimsey and Bunter. Wimsey then improvises a new code, based on an unpublished text known only to himself and his wife.
* Graham Greene's protagonists often use book codes. In The Human Factor, several books are used, and an edition of Charles Lamb's Tales from Shakespeare is used in Our Man in Havana.
* A book cipher plays an important role in the TV version of Sharpe's Sword. The key text is Voltaire's Candide.
* In the 2004 film National Treasure, a book cipher (called an "Ottendorf cipher") is discovered on the back of the U.S. Declaration of Independence, using the "Silence Dogood" letters as the key text.
* The protagonists of the Matthew Reilly novel The Six Sacred Stones used a book cipher to send confidential messages to each other. The key text was the Harry Potter books, but the messages were sent via a The Lord of the Rings forum to make the key text harder to identify.
* In Lost: Mystery of the Island, a series of four jigsaw puzzles released in 2007, a book cipher was used on each puzzle's box to hide spoilers and reveal information about the show to the fans.
* "The Fisher King", a two-part episode of Criminal Minds, features a book cipher brought to the Behavioral Analysis Unit by the UNSUB via Agent Hotchner's wife. The cypher was part of a larger puzzle to find a girl who had been missing for two years. The key text was The Collector by John Fowles.
* Burn Notice (episodes "Where There's Smoke" and "Center of the Storm", 2010): Michael Westen steals a Bible from a safe deposit box that is the code book of Simon. This becomes part of the season plot to track an organization starting wars for profit as Michael tries to arrange an interview with Simon.
* In the episode "The Blind Banker" of the BBC series Sherlock, Sherlock Holmes searches for a book that is the key to a cipher being used by Chinese Tong smugglers to communicate with their agents and with each other through graffiti messages. He eventually finds it: the London A-Z.
* In the film Unknown (2011), Prof. Bressler's passwords are obscured by a book cipher.
* In The Unit episode "Paradise Lost", Jonas Blane (a.k.a. Snake Doctor) uses a book code from the poem Paradise Lost to communicate to his wife, Molly, that he has arrived safely in Panama.
* In The Good Soldier Švejk by Jaroslav Hašek, the officers in Švejk's battalion attempt to use a book cipher. Their attempts are undone, however, when it is revealed that the novel in question is composed of two volumes, and Švejk has delivered the first volume to the officers, thinking that they intended to read the novel, rather than the second, which is used for the cipher. Furthermore, the key to the cipher is identical to an example given in a published military textbook.
* In An Instance of the Fingerpost, a historical mystery by Iain Pears, a book cipher conceals one character's family history and its relationship with the English Civil War.
* In John Le Carre's A Perfect Spy, the protagonist Magnus Pym uses a book cipher based on the German text Simplicissimus.
* In the book Red Dragon, Hannibal Lecter uses a book code to encrypt a message to the Tooth Fairy killer, with the message containing the home address of Will Graham, who is investigating the case, and the message, "Save yourself. Kill them all", with the intent of having Will and his family fall victim to the killer. In the 1986 film adaptation Manhunter, the book used is mentioned to be a list of statues in the state of Maryland. In the 2002 adaptation Red Dragon, the book is changed to the French cooking encyclopedia Larousse Gastronomique to fit in with that movie's depiction of Lecter.
* In The Darwin Code by J D Welch, Jess uses a Shakespearean speech to construct a book cipher to communicate with an enemy who may or may not be an ally.
* In Bitterblue by Kristin Cashore, Bitterblue uses a book(?) code to unlock secrets of her father's reign as king.
* In the TV series Deutschland 83, protagonist Martin Rauch's East German handlers use a book cipher to communicate with him while he is undercover in West Germany.
* In the series 2 finale of the BBC TV show Luther, two brothers use a book cipher. Luther determines they must be using a book that is readily available in case the book is lost and/or so the users can always have it to hand. This leads him to discovering the book cipher is using Gideon's Bible.