Poe published The Gold-Bug in 1843 and taught a generation of Americans that ciphers could be broken by counting letters. The story launched cipher fiction in the US. Here is how Legrand's frequency analysis works.
Edgar Allan Poe published "The Gold-Bug" in the Philadelphia Dollar Newspaper on June 21, 1843. It won the newspaper's writing contest, sold widely, and did something no American story had done before: it made cryptanalysis a plot device that ordinary readers could follow.
The story features a substitution cipher on a piece of parchment, left by the pirate Captain Kidd. The protagonist, William Legrand, solves it using letter frequency analysis. Poe walks the reader through the method. The most common symbol in the ciphertext is probably E, because E is the most common letter in English. From there, you guess, test, and fill in the rest.
Poe was not the first person to describe frequency analysis. The technique was documented by the Arab polymath Al-Kindi in the 9th century in his Manuscript on Deciphering Cryptographic Messages. But Poe was the first writer in English to put the method into a popular story and make it the engine of the plot. The result was a small but real shift in how Americans thought about secret writing.
You can try the exact cipher from the story with our Gold Bug Cipher tool, and analyze your own text with our Letter Frequency Analyzer.
Before "The Gold-Bug," Poe spent years building a public reputation as a codebreaker. In December 1839, writing in Alexander's Weekly Messenger, a Philadelphia newspaper, Poe dared his readers to send him substitution ciphers. He claimed he would solve any single-substitution cipher they submitted.
He solved most of them. Over the following months, he published solutions to reader-submitted ciphers and used the column to explain his methods. The challenge was part entertainment and part marketing. Poe was building a persona: the rational analyst who could see through any disguise. This was the same persona he used in his detective stories featuring C. Auguste Dupin, which predate Sherlock Holmes by nearly half a century.
Not every solution was correct. Poe occasionally made errors or accepted ciphers that did not have unique solutions, and some readers sent ciphers in languages he did not know. But the column established two ideas in the American popular imagination: that ciphers were breakable by systematic analysis, and that the analysis was something a clever person could learn.
This background mattered when "The Gold-Bug" appeared. Readers who had followed the Alexander's challenges already understood the premise. Poe was not introducing a brand-new idea. He was dramatizing a method he had been demonstrating in public for years.
The Poe Society of Baltimore maintains an archive of Poe's writings, including the cipher challenge columns, and the Wikipedia article on The Gold-Bug provides a consolidated summary with citations to the original newspaper publications.
The plot of "The Gold-Bug" is straightforward. William Legrand, an eccentric man living on Sullivan's Island near Charleston, South Carolina, catches a gold-colored beetle. He draws the beetle on a piece of parchment he happens to be carrying. The drawing is invisible to his companion, the narrator, until Legrand holds it near a fire. The heat reveals a hidden cipher written in invisible ink on the parchment.
The cipher is a string of numbers, symbols, and a few letters. Legrand recognizes it as a substitution cipher and sets about solving it. Once decoded, the message gives directions to the buried treasure of Captain Kidd. Legrand, the narrator, and Legrand's servant Jupiter follow the directions, dig at the specified spot, and find the treasure.
The cipher text in the story runs as follows (reproduced in Poe's original):
53‡‡†305))6;4826)4‡.)4‡);806;48†8¶60))85;]8;:‡8†83(88)5†;46(;8896?;8)‡(;485);5†2:‡(;49562(5-4)8¶8;4069285);)6†8)4‡‡;1(‡9;48081;8:8‡1;48†85;4)485†52880681(‡9;48;(88;4(‡?34;48)4‡;161;:188;‡?;
Legrand's explanation of how he solves it is the technical heart of the story. He counts the occurrences of each symbol. The most frequent symbol is 8, so he assigns it to E. He then looks for a common three-letter pattern that ends in E, guessing it is "the," which gives him T and H. From there he identifies A, I, O, N, and so on, building the key one letter at a time.
The decoded message reads (in Poe's text): "A good glass in the bishop's hostel in the devil's seat forty-one degrees and thirteen minutes northeast and by north main branch seventh limb east side shoot from the left eye of the death's-head a bee-line from the tree through the shot fifty feet out."
You can encode and decode text using Poe's exact substitution alphabet with our Gold Bug Cipher tool.
Legrand's method is frequency analysis, and Poe's explanation of it is reasonably accurate for a simple monoalphabetic substitution cipher.
The underlying principle is that in any natural language, letters occur with predictable frequencies. In English, E is the most common letter, followed by T, A, O, I, N, S, H, R, D, L, and U. The exact order varies by corpus, but the rough ranking is stable. In a monoalphabetic substitution cipher, each plaintext letter is replaced by a fixed symbol. The frequency distribution of the ciphertext symbols therefore mirrors the frequency distribution of the plaintext letters. The most common ciphertext symbol is probably the substitute for E.
Legrand counts the symbols in the ciphertext and finds that 8 appears most often. He assigns 8 to E. He then looks for a three-symbol sequence that ends in 8 and appears frequently, guessing it represents "the." This gives him the symbols for T and H. He continues, using common English digraphs (TH, HE, AN, RE) and short words to fill in more letters.
This is the same method Al-Kindi described in the 9th century. Al-Kindi's Manuscript on Deciphering Cryptographic Messages is the earliest known written treatment of frequency analysis, and it laid out the core ideas: count letters, compare to known language frequencies, use word patterns. The method reached Europe through later Arabic and European scholarship, but it was not widely known to the general public in the United States before Poe.
Poe's presentation has one simplification. He treats the frequency ranking as deterministic rather than statistical. In practice, short ciphertexts can deviate significantly from the expected frequency distribution, and a single wrong guess can cascade into nonsense. Real frequency analysis requires iteration and backtracking. But for a popular story, Poe's explanation is honest about the core idea, which is more than most fiction manages.
Our Letter Frequency Analyzer](/tools/letter-frequency-analyzer) lets you run the same counting on any text, and our Substitution Cipher Helper lets you test candidate keys interactively. The [Khan Academy cryptography course covers frequency analysis with worked examples for learners who want the full method.
"The Gold-Bug" was a commercial success. It was reprinted widely in American and European newspapers and magazines. Poe reportedly earned $100 for the prize submission, and the story sold over 300,000 copies during his lifetime, which was unusual for a short story in the 1840s.
The story's influence on fiction was direct. Jules Verne cited Poe as a major influence and wrote cipher-based puzzles into his own work. The genre of the cryptographic puzzle story, where the reader is invited to solve a cipher alongside or ahead of the protagonist, grew out of "The Gold-Bug" and the Alexander's challenges. Later examples range from Arthur Conan Doyle's "The Adventure of the Dancing Men" to modern CTF writeups.
The influence on American popular cryptography was subtler but real. Before Poe, ciphers in American popular writing were usually presented as magical or unbreakable. After Poe, they were presented as puzzles that yielded to method. This framing matters. It is the difference between thinking of a cipher as a lock that only the keyholder can open and thinking of it as a statistical problem that a sufficiently patient analyst can solve.
That framing is the foundation of modern cryptanalysis. When Friedman, Rowlett, and the SIS team attacked Japanese ciphers in the 1930s, or when Bletchley Park attacked Enigma in the 1940s, they were working in the intellectual tradition that Poe had popularized: ciphers are not magic, they are mathematics, and mathematics can be beaten by better mathematics.
Poe did not invent frequency analysis, and he did not break any cipher that mattered to national security. What he did was show the American reading public that the method existed and that it worked. For a writer who died in 1849 at age 40, largely broke and underappreciated, that is a non-trivial legacy.
You can explore the cipher yourself with our Gold Bug Cipher tool, compare it to a simple shift cipher with our Caesar Cipher tool, or read our Frequency Analysis Explained post for the full mathematical method.
The cipher in The Gold-Bug is a monoalphabetic substitution cipher that uses numbers and typographic symbols instead of letters. Each plaintext letter maps to a fixed symbol. The protagonist, William Legrand, breaks it using frequency analysis, counting the symbols and matching the most common one to the letter E.
Frequency analysis was documented by the Arab polymath Al-Kindi in the 9th century in his Manuscript on Deciphering Cryptographic Messages. The method reached Europe through later scholarship. Poe encountered it through his reading and demonstrated it publicly in his Alexander's Weekly Messenger cipher challenges from 1839 to 1840, before dramatizing it in The Gold-Bug.
The Gold-Bug was published on June 21, 1843, in the Philadelphia Dollar Newspaper, where it won a writing contest. It was widely reprinted and sold over 300,000 copies during Poe's lifetime, making it one of his most popular works.
Yes, for a simple substitution cipher. Poe correctly identifies E as the most common English letter and uses common word patterns like 'the' to bootstrap the key. The method is simplified for narrative purposes, since real frequency analysis requires iteration and backtracking on short texts, but the core technique is sound.
Yes. The Gold-Bug is considered the origin point of cipher fiction in America. Jules Verne cited Poe as a major influence. The genre of stories where the reader is invited to solve a cipher alongside the protagonist grew directly from Poe's story and his earlier Alexander's Weekly Messenger cipher challenges.
Gold Bug Cipher
Encode and decode the Gold Bug cipher from Edgar Allan Poe's 1843 short story, a monoalphabetic substitution using digits and typographic symbols broken by frequency analysis.
Letter Frequency Analyzer
Count and analyze letter frequencies in text for cryptogram solving.
Substitution Cipher Helper
Tools and utilities for solving substitution cipher puzzles.
Caesar Cipher
Encrypt or decrypt messages by shifting letters through the alphabet.
Frequency Analysis Explained: How to Break Any Substitution Cipher
Al-Kindi discovered frequency analysis in 9th-century Baghdad. The technique still breaks CTF substitution ciphers today. Here is how it works and how to apply it.
The Caesar Cipher: History, Math, and Two Ways to Break It
Julius Caesar shifted letters by 3. Suetonius documented it around 121 CE. Learn the exact math, the ROT13 self-inverse property, and how brute force and frequency analysis break it in seconds.