My middle school years were spent in an English-medium school in India. Among our assigned literature readings was a story by Edgar Allan Poe called "The Gold-Bug." This story sparked in me an interest in cryptography, the science of secret messages.
Cryptography is a vital field today in computer science. Modern life would grind to a halt without recent advances in it. You wouldn't be able to identify yourself to your bank or verify information anyone gives you. Several of the key engineers and mathematicians who contributed to cryptography since World War II trace their own interest to having read this story in their childhoods.
The Gold-Bug and Poe
The Gold-Bug is not much of a story, as far as plot and character go. While collecting a rare beetle on a beach, a white man and his black manservant discover an old parchment paper with a message written in strange symbols, some sort of secret code.
The story spends most of its pages explaining how the man cracks the code to discover where a pirate's treasure was buried.
At the time, I had no idea who Edgar Allan Poe was, and how old this story was. But since coming to Boston, where he was born and where the city has a statue of him on Boylston Street, I've learned more about the tortured writer's life and his obsessions. His 215th birthday would have been last week.
It was around 1840 that Poe's fascination with logic and reasoning led him to study the encoding of information. In those days, most people thought of the art of writing secret messages as a kind of occult magic. Poe, however, ever the rationalist, dismissed such fancies. Anyone could write and break secret messages via logical reasoning.
He wrote "The Gold-Bug" as an introduction to the topic, then submitted it to a Philadelphia newspaper's writing contest and won a hundred dollars for it. The paper published it in 1843. It's probably the oldest piece of fiction to incorporate cryptography, and certainly the first to use the term.
The Puzzle
The secret message in the story is an example of a simple substitution cipher, where each letter in a piece of text is replaced by some number or symbol. To read the message, you need a key, a table that shows which symbol stands for which letter.
(You can read the article on the website, if you prefer)
These substitution ciphers can be decoded without a key by systematically applying logical reasoning and exploring different possibilities.
Assuming the message is in English, you start with a table of how frequently various letters, sequences of letters, and words appear in typical English-language text: e is the most frequent letter, followed by taoinshrdl and so on. In the story, the protagonist counts the frequencies of the symbols on the parchment and writes out an entire table: 8 is the most frequent character, followed by semicolon, then 4, and so on.
This analysis gives you a place to start. Perhaps 8 stands for e, semicolon stands for t, etc. You try these substitutions, and if you see mistakes, you can change them until you have figured out the key.
This kind of analysis is similar to the mathematical models needed to generate text, as I discussed in an earlier blog post about ChatGPT. (Claude Shannon said he read The Gold-Bug as a child).
Addendum
When I first read this story in middle school, I used the cipher devised by the protagonist to uncover the secret message. But the resulting message was not correct: it produced the word "fosty" instead of "forty."
The story as published in various outlets has different mistakes in the typography of the parchment paper. I have seen at least three different versions with different mistakes.
The version in the picture above is the scan in the Gutenberg website. It has the same mistake as the one I read, producing the word "fosty" in the resulting message. But it couldn't have been Poe's fault. By the time he wrote The Gold-Bug, Poe had done a pretty thorough analysis of hundreds of messages submitted by his readers in response to his essays on cryptography in another magazine.
Fortunately, we now have the original version of the story painstakingly scanned and proof-read by The Edgar Allan Poe Society of Baltimore on their website. They have scanned The Gold-Bug from the original Dollar Newspaper, where it appears without any mistakes:
Enjoy!