The Dark Cave

Deep below The Village...

Suppose Number 70 has intercepted the cryptogram below, and it is known to be encrypted using a simple substitution cipher as follows:


For this example, uppercase letters are used to denote ciphertext, lowercase letters are used to denote plaintext (or guesses at such), and Xt is used to express a guess that ciphertext letter X represents the plaintext letter t.

Number 70 could use frequency analysis to help solve the message along the following lines: counts of the letters in the cryptogram show that I is the most common single letter, XL most common bigram, and XLI is the most common trigram. "e" is the most common letter in the English language, "th" is the most common bigram, and "the" is the most common trigram. This strongly suggests that Xt, Lh and Ie. The second most common letter in the cryptogram is E; since the first and second most frequent letters in the English language, e and t are accounted for, Eve guesses that Ea, the third most frequent letter. Tentatively making these assumptions, the following partial decrypted message is obtained.


Using these initial guesses, Number 70 can spot patterns that confirm her choices, such as "that". Moreover, other patterns suggest further guesses. "Rtate" might be "state", which would mean Rs. Similarly "atthattMZe" could be guessed as "atthattime", yielding Mi and Zm. Furthermore, "heVe" might be "here", giving Vr. Filling in these guesses, Number 70 gets:

hereTCSWPeYraWHarSseQithaYraOeaWHstatePFairaWHKrSTYhtmetheKeetPeJrSmaYPassGasei WQhiGhitQaseWGPSseHitQasaKeaTtiJTPsGaraKaeTsaWHatthattimeTWAWSQWtSWatTraPistsSJ GSTrseaYreatCriUeiWasGieWtiJiGCSiWtSJOieQthereQeretQSrSTWHKPaGAsCStsWearSWeeBtr emitFSJtheKaGAaWHaPSWYSWeWeartheStherthesGaPesQereeBGeeHiWYPFharHaWHYPSssFQitha PPtheaCCearaWGeSJKTrWisheHYSPHtheQeiYhtSJtheiWseGtQasOerFremarAaKPeaWHtaAiWYaPP thiWYsiWtSGSWsiHeratiSWiGSTPHharHPFKPameNTCiterJSrhisSCiWiSWresCeGtiWYit

In turn, these guesses suggest still others (for example, "remarA" could be "remark", implying Ak) and so on, and it is relatively straightforward to deduce the rest of the letters, eventually yielding the plaintext.

hereuponlegrandarosewithagraveandstatelyairandbroughtmethe beetlefromaglasscaseinwhichitwasencloseditwasabeautifulscarabaeusandatthattimeu nknowntonaturalistsofcourseagreatprizeinascientificpointofviewthereweretworound blackspotsnearoneextremityofthebackandalongoneneartheotherthescaleswereexceedin glyhardandglossywithalltheappearanceofburnishedgoldtheweightoftheinsectwasveryr emarkableandtakingallthingsintoconsiderationicouldhardlyblamejupiterforhisopini onrespectingit

At this point, it would be a good idea for Number 70 to insert spaces and punctuation: Hereupon Legrand arose, with a grave and stately air, and brought me the beetle from a glass case in which it was enclosed. It was a beautiful scarabaeus, and, at that time, unknown to naturalists—of course a great prize in a scientific point of view. There were two round black spots near one extremity of the back, and a long one near the other. The scales were exceedingly hard and glossy, with all the appearance of burnished gold. The weight of the insect was very remarkable, and, taking all things into consideration, I could hardly blame Jupiter for his opinion respecting it.

In this example from The Gold-Bug, Number 70's guesses were all correct. This would not always be the case, however; the variation in statistics for individual plaintexts can mean that initial guesses are incorrect. It may be necessary to backtrack incorrect guesses or to analyze the available statistics in much more depth than the somewhat simplified justifications given in the above example.

It is also possible that the plaintext does not exhibit the expected distribution of letter frequencies. Shorter messages are likely to show more variation. It is also possible to construct artificially skewed texts. For example, entire novels have been written that omit the letter "e" altogether — a form of literature known as a lipogram.

Adapted from

Other useful information is available:

Frequency analysis List of letters

Frequency analysis Common letter pairs

Frequency analysis Letter Frequencies