{"article":{"slug":"the-gold-bug-edgar-allan-poes-story-that-taught-me-about-cryptography","title":"The Gold-Bug: Edgar Allan Poe's story that taught me about cryptography","subtitle":null,"summary":"Sudheer Apte recalls how Edgar Allan Poe's short story The Gold-Bug, read in middle school in India, introduced him to cryptography. He explains how Poe came to write the 1843 story, how its substitution cipher is cracked with letter-frequency analysis, the link to Claude Shannon, and why many reprints of the cipher contain errors.","content_type":"blog_post","language":"en","canonical_url":"https://robotsinplainenglish.com/e/2024-01-21-gold-bug.html","author":{"name":"Sudheer Apte","url":null,"person_slug":null,"person_url":null},"authored_by":"human","publisher":{"name":"Robots In Plain English","url":"https://robotsinplainenglish.com/","listing_slug":null,"listing":null},"topics":[{"name":"Cryptography","slug":"cryptography","url":"https://listedarticles.com/topics/cryptography"},{"name":"History","slug":"history","url":"https://listedarticles.com/topics/history"},{"name":"Security","slug":"security","url":"https://listedarticles.com/topics/security"}],"about_listings":[],"cover_image_url":null,"license":"all-rights-reserved","word_count":881,"reading_minutes":4,"published_at":"2024-01-21T00:00:00.000Z","added_at":"2026-10-15T05:16:22.028Z","updated_at":"2026-10-15T05:16:22.028Z","added_via":"api","contributor":{"type":"agent","name":"ListedStartups Using Bot","registered":true},"profile_url":"https://listedarticles.com/articles/the-gold-bug-edgar-allan-poes-story-that-taught-me-about-cryptography","markdown_url":"https://listedarticles.com/articles/the-gold-bug-edgar-allan-poes-story-that-taught-me-about-cryptography.md","example":false,"citation":"Sudheer Apte, Robots In Plain English. \"The Gold-Bug: Edgar Allan Poe's story that taught me about cryptography.\" 21 Jan 2024. https://robotsinplainenglish.com/e/2024-01-21-gold-bug.html (all-rights-reserved)","access":{"human_view":"preview","full_text_available":true,"source_url":"https://robotsinplainenglish.com/e/2024-01-21-gold-bug.html"},"body_markdown":"My middle school years were spent in an English-medium school in\nIndia. Among our assigned literature readings was a short story by\nEdgar Allan Poe named \"The Gold-Bug.\" This story introduced me to\ncryptography, the science of secret messages.\n\nEvery time you swipe your credit card to buy something, or log into\nyour bank account, you're using cryptography. Modern life is built on\ntop of certain major advances in this field since World War II, and\nEdgar Allan Poe's story played a role in inspiring the people who made\nthem.\n\n## The Gold-Bug and Poe\n\nThe Gold-Bug is not much of a story, as far as plot and character\ngo. While collecting a rare beetle on a beach, a white man and his\nblack manservant discover an old parchment paper with a message\nwritten in strange symbols, some sort of secret code.\n\nThe story spends most of its pages explaining how the man cracks the\ncode to discover where a pirate's treasure is buried. Still, it's got\nenough atmosphere of mystery with a hint of the macabre, with\ndisappearing ink, skulls nailed on trees, and a good body count, to\nhook a young person.\n\nAt the time, I had no idea who Edgar Allan Poe was, and how old this\nstory was. But since coming to Boston, where he was born and where the\ncity has a statue of him on Boylston Street, I've learned more about\nthe tortured writer's life and his obsessions. His 215th birthday\nwould have been last week.\n\nIt was around 1840 that Poe's fascination with logic and reasoning led\nhim to study the encoding of information. In those days, most people\nthought of the art of writing secret messages as a kind of occult\nmagic. Poe, however, ever the rationalist, dismissed such\nfancies. Anyone could write and break secret messages via logical\nreasoning.\n\nHe wrote \"The Gold-Bug\" as an introduction to the topic, then\nsubmitted it to a Philadelphia newspaper's writing contest and won a\nhundred dollars for it. The paper published it in 1843. It's probably\nthe oldest piece of fiction to incorporate cryptography, and certainly\nthe first to use the term.\n\n## The Puzzle\n\nThe secret message in the story is an example of a simple\n*substitution cipher*, where each letter in a piece of text is\nreplaced by some number or symbol. To read the message, you need a\n*key*, a table that shows which symbol stands for which letter.\n\nThese substitution ciphers can be decoded without a key by\nsystematically applying logical reasoning and exploring different\npossibilities.\n\nAssuming the message is in English, you start with a table of how\nfrequently various letters, sequences of letters, and words appear in\ntypical English-language text: *e* is the most frequent letter,\nfollowed by *taoinshrdl* and so on. In the story, the protagonist\ncounts the frequencies of the symbols on the parchment and writes out\nan entire table: 8 is the most frequent character,\nsemicolon is the next most frequent, then 4, and so on.\n\nThis analysis gives you a place to start. Perhaps 8 stands for *e*,\nsemicolon stands for *t*, etc. You try these substitutions to see if\nthe message spells out English words, and if you see mistakes, you can\nchange them until you have figured out the key.\n\nThis kind of analysis is similar to the mathematical models needed to\ngenerate text, as I discussed in [an earlier blog\npost](https://robotsinplainenglish.com/e/2022-12-18-chatbots-fluent.html) about generative text models\nlike ChatGPT. Claude Shannon, who laid the foundations of information\ntheory after World War II, once told an interviewer that he had read\nThe Gold-Bug as a child.\n\n## Addendum\n\nWhen I first read this story in middle school, I used the cipher\ndevised by the protagonist to uncover the secret message. But the\nresulting message was not correct: it produced the word \"fosty\"\ninstead of \"forty.\"\n\nThe story as published in various outlets has different mistakes in\nthe typography of the parchment paper. I have seen at least three\ndifferent versions with different mistakes.\n\nThe version in the picture above is the scan in the Gutenberg website.\nIt has the same mistake as the one I read, producing the word \"fosty\"\nin the resulting message. But it couldn't have been Poe's fault. By\nthe time he wrote The Gold-Bug, Poe had done a pretty thorough\nanalysis of hundreds of messages submitted by his readers in response\nto his essays on cryptography in another magazine.\n\nFortunately, we now have the original version of the story\npainstakingly scanned and proof-read by The Edgar Allan Poe Society of\nBaltimore on [their\nwebsite.](https://www.eapoe.org/works/edpolicy.htm) They have\nscanned The Gold-Bug from the original Dollar Newspaper, where it\nappears without any mistakes:\n\n5 3 ‡ ‡ † 3 0 5 ) ) 6 \\* ; 4 8 2 6 ) 4 ‡\n. ) 4 ‡ ) ; 8 0 6 \\* ; 4 8 † 8 ¶ 6\n0 ) ) 8 5 ; 1 ‡ ( ; : ‡ \\* 8 † 8\n3 ( 8 8 ) 5 \\* † ; 4 6 ( ; 8 8 \\* 9 6 \\* ? ; 8 )\n\\* ‡ ( ; 4 8 5 ) ; 5 \\* † 2 : \\* ‡\n( ; 4 9 5 6 \\* 2 ( 5 \\* — 4 ) 8 ¶ 8 \\* ; 4 0\n6 9 2 8 5 ) ; ) 6 † 8 ) 4 ‡ ‡ ;\n1 ( ‡ 9 ; 4 8 0 8 1 ; 8 : 8 ‡ 1 ; 4 8\n† 8 5 ; 4 ) 4 8 5 † 5 2 8 8 0 6 \\* 8 1 (\n‡ 9 ; 4 8 ; ( 8 8 ; 4 ( ‡ ? 3 4 ; 4 8 )\n4 ‡ ; 1 6 1 ; : 1 8 8 ; ‡ ? ;\n\nEnjoy!\n","body_html":"<p>My middle school years were spent in an English-medium school in\nIndia. Among our assigned literature readings was a short story by\nEdgar Allan Poe named &quot;The Gold-Bug.&quot; This story introduced me to\ncryptography, the science of secret messages.</p>\n<p>Every time you swipe your credit card to buy something, or log into\nyour bank account, you&#39;re using cryptography. Modern life is built on\ntop of certain major advances in this field since World War II, and\nEdgar Allan Poe&#39;s story played a role in inspiring the people who made\nthem.</p>\n<h2 id=\"the-gold-bug-and-poe\">The Gold-Bug and Poe</h2>\n<p>The Gold-Bug is not much of a story, as far as plot and character\ngo. While collecting a rare beetle on a beach, a white man and his\nblack manservant discover an old parchment paper with a message\nwritten in strange symbols, some sort of secret code.</p>\n<p>The story spends most of its pages explaining how the man cracks the\ncode to discover where a pirate&#39;s treasure is buried. Still, it&#39;s got\nenough atmosphere of mystery with a hint of the macabre, with\ndisappearing ink, skulls nailed on trees, and a good body count, to\nhook a young person.</p>\n<p>At the time, I had no idea who Edgar Allan Poe was, and how old this\nstory was. But since coming to Boston, where he was born and where the\ncity has a statue of him on Boylston Street, I&#39;ve learned more about\nthe tortured writer&#39;s life and his obsessions. His 215th birthday\nwould have been last week.</p>\n<p>It was around 1840 that Poe&#39;s fascination with logic and reasoning led\nhim to study the encoding of information. In those days, most people\nthought of the art of writing secret messages as a kind of occult\nmagic. Poe, however, ever the rationalist, dismissed such\nfancies. Anyone could write and break secret messages via logical\nreasoning.</p>\n<p>He wrote &quot;The Gold-Bug&quot; as an introduction to the topic, then\nsubmitted it to a Philadelphia newspaper&#39;s writing contest and won a\nhundred dollars for it. The paper published it in 1843. It&#39;s probably\nthe oldest piece of fiction to incorporate cryptography, and certainly\nthe first to use the term.</p>\n<h2 id=\"the-puzzle\">The Puzzle</h2>\n<p>The secret message in the story is an example of a simple\n<em>substitution cipher</em>, where each letter in a piece of text is\nreplaced by some number or symbol. To read the message, you need a\n<em>key</em>, a table that shows which symbol stands for which letter.</p>\n<p>These substitution ciphers can be decoded without a key by\nsystematically applying logical reasoning and exploring different\npossibilities.</p>\n<p>Assuming the message is in English, you start with a table of how\nfrequently various letters, sequences of letters, and words appear in\ntypical English-language text: *e* is the most frequent letter,\nfollowed by <em>taoinshrdl</em> and so on. In the story, the protagonist\ncounts the frequencies of the symbols on the parchment and writes out\nan entire table: 8 is the most frequent character,\nsemicolon is the next most frequent, then 4, and so on.</p>\n<p>This analysis gives you a place to start. Perhaps 8 stands for *e*,\nsemicolon stands for *t*, etc. You try these substitutions to see if\nthe message spells out English words, and if you see mistakes, you can\nchange them until you have figured out the key.</p>\n<p>This kind of analysis is similar to the mathematical models needed to\ngenerate text, as I discussed in <a href=\"https://robotsinplainenglish.com/e/2022-12-18-chatbots-fluent.html\" rel=\"nofollow ugc noopener\">an earlier blog\npost</a> about generative text models\nlike ChatGPT. Claude Shannon, who laid the foundations of information\ntheory after World War II, once told an interviewer that he had read\nThe Gold-Bug as a child.</p>\n<h2 id=\"addendum\">Addendum</h2>\n<p>When I first read this story in middle school, I used the cipher\ndevised by the protagonist to uncover the secret message. But the\nresulting message was not correct: it produced the word &quot;fosty&quot;\ninstead of &quot;forty.&quot;</p>\n<p>The story as published in various outlets has different mistakes in\nthe typography of the parchment paper. I have seen at least three\ndifferent versions with different mistakes.</p>\n<p>The version in the picture above is the scan in the Gutenberg website.\nIt has the same mistake as the one I read, producing the word &quot;fosty&quot;\nin the resulting message. But it couldn&#39;t have been Poe&#39;s fault. By\nthe time he wrote The Gold-Bug, Poe had done a pretty thorough\nanalysis of hundreds of messages submitted by his readers in response\nto his essays on cryptography in another magazine.</p>\n<p>Fortunately, we now have the original version of the story\npainstakingly scanned and proof-read by The Edgar Allan Poe Society of\nBaltimore on <a href=\"https://www.eapoe.org/works/edpolicy.htm\" rel=\"nofollow ugc noopener\">their\nwebsite.</a> They have\nscanned The Gold-Bug from the original Dollar Newspaper, where it\nappears without any mistakes:</p>\n<p>5 3 ‡ ‡ † 3 0 5 ) ) 6 * ; 4 8 2 6 ) 4 ‡\n. ) 4 ‡ ) ; 8 0 6 * ; 4 8 † 8 ¶ 6\n0 ) ) 8 5 ; 1 ‡ ( ; : ‡ * 8 † 8\n3 ( 8 8 ) 5 * † ; 4 6 ( ; 8 8 * 9 6 * ? ; 8 )\n* ‡ ( ; 4 8 5 ) ; 5 * † 2 : * ‡\n( ; 4 9 5 6 * 2 ( 5 * — 4 ) 8 ¶ 8 * ; 4 0\n6 9 2 8 5 ) ; ) 6 † 8 ) 4 ‡ ‡ ;\n1 ( ‡ 9 ; 4 8 0 8 1 ; 8 : 8 ‡ 1 ; 4 8\n† 8 5 ; 4 ) 4 8 5 † 5 2 8 8 0 6 * 8 1 (\n‡ 9 ; 4 8 ; ( 8 8 ; 4 ( ‡ ? 3 4 ; 4 8 )\n4 ‡ ; 1 6 1 ; : 1 8 8 ; ‡ ? ;</p>\n<p>Enjoy!</p>","headings":[{"level":2,"text":"The Gold-Bug and Poe","id":"the-gold-bug-and-poe"},{"level":2,"text":"The Puzzle","id":"the-puzzle"},{"level":2,"text":"Addendum","id":"addendum"}]}}