Book Cipher

Encode each word as a line and word position reference into a shared text.

Free book cipher encoder and decoder. Replaces each word of your message with a line-and-word reference into a pasted reference text (the shared book), and decodes references back to words. A classic key-text cipher needing only an agreed passage. Runs entirely in your browser. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

How does a book cipher work?

Both parties agree on a shared text — a book, article or page. Each word of the secret message is replaced by a reference pointing to a copy of that same word inside the shared text, such as its line number and position on the line. Anyone without the exact text cannot resolve the references.

A book cipher is a key-text cipher: instead of a fixed algorithm, its security rests on a shared passage of text known to both the sender and the receiver. Each word of the secret message is replaced with a reference pointing to where that same word appears in the shared text. To anyone without the exact passage, the message is just a meaningless list of numbers.

Historical background

Book ciphers have been used for centuries as a practical alternative to complex mechanical cipher devices. Their appeal is simple: the key is a seemingly innocent document that both parties already possess. Intelligence agencies, resistance fighters, and spies have historically used published books, newspaper articles, or legal texts as shared references, since possessing a copy of a common book arouses no suspicion. The Ottendorf cipher — a three-number page.line.word variant — is the most well-known form.

How it works

This tool uses a simple line.word reference scheme. The reference text is split into lines, and each line into words. To encode, the tool takes each word of your message, searches the reference text for a matching word (case-insensitively), and emits a reference of the form line.word — for example 3.5 meaning the 5th word on the 3rd line.

To decode, each line.word reference is resolved by jumping to that line and counting along to that word, returning the original text found there. Because the lookup is positional, the two sides only need to agree on the exact same reference text — no other key is required.

Worked example

Suppose the reference text is:

the quick brown fox
jumps over the lazy dog

To encode the message the dog, the tool finds the as the 1st word on line 1 (1.1) and dog as the 5th word on line 2 (2.5), giving the ciphertext 1.1 2.5. Decoding 1.1 2.5 with the same passage walks straight back to the dog.

A slightly more complex message — fox jumps over the — encodes to 1.4 2.1 2.2 1.1 using the same passage. Notice that the appears twice (line 1 word 1 and line 2 word 3); the encoder picks the first match, though in principle any occurrence is valid.

Strength and limitations

The book cipher’s security comes entirely from keeping the reference text secret. If the interceptor knows the book but not which page or section you are using, they must try every subset of the text. If they do not know the book at all, the cipher is extremely difficult to break because frequency analysis fails — the numbers give away nothing about the underlying words.

The key weaknesses are:

  • Vocabulary coverage: a word that does not appear in the reference text cannot be encoded. This is why longer, diverse reference texts (novels, articles) work better than short passages.
  • Key management: both parties must hold the exact same version of the text, including the same line breaks. A different edition of a book with different pagination will break decoding.
  • Reuse risk: using the same reference text repeatedly for multiple messages gives an analyst statistical leverage to narrow down which text is being used.

Practical tips

  • Choose a long, varied reference passage to maximise vocabulary coverage.
  • Avoid using well-known texts (classic novels, the Bible) if real secrecy matters; prefer private documents known only to you and your correspondent.
  • Words not found in the reference are flagged so you can rephrase the message or choose a richer passage.
  • Everything runs locally in your browser; nothing is uploaded.