It seems to be a common fantasy trope, that a dungeon or hidden treasure can be accessed by solving a puzzle or riddle (occasionally featuring helpful hints in the form of a poem). They can be mechanical, magical, or the combination of both.

Of course, the purpose of a real security system is to differentiate between authorized and unauthorized personnel, based on a combination of the following:

  • something you posses. For example, a key you keep on your person or distribute only to trusted underlings, and not a key which is hidden among a few other keys at the location, with a poem containing a riddle how to choose the correct one, if the intruder even cares to solve it instead of just brute forcing all of them.
  • something you know. For example, a password or a number sequence you memorize and only tell to trusted underlings, and not the solution of a riddle inscribed next to the locked door.
  • something you are. In modern times it can be biometric data, in fantasy it can be your race or bloodline. Still, the latter one could include a large number of people you wouldn't want accessing your hidden base.

Instead of the above, in fantasy it's common to use riddles, which anyone lucky or smart enough can solve, this defeats the whole purpose of having a locked entryway.

Please note, that this question is about riddles or puzzles being used where the intention was to keep unauthorized access away from something the creator of the riddle wants to keep away from trespassers. Therefore, the following types of riddles or puzzles are not answers to the question:

  • the makers of the puzzle do it out of sheer curiosity or boredom, or just to have fun or screw with the people (like the myth of the Sphinx)
  • the makers of the puzzle do it as a way to test people, or to gift eligible people with their treasure.

To fulfill the criteria of the question, the riddle or puzzle must be an honest (but misguided) effort to protect something, and prevent access from anyone who doesn't already know the solution. Of course, inevitably, someone will solve the puzzle and gain access who the creator of the puzzle didn't intend to do so.

If the earliest example is mythological, it would be nice to include the earliest work of fiction additionally to it.

  • 5
    So a puzzle as an old timey password reminder? If you did not request passage please ignore this riddle. Please do not respond by hitting the 'reply' button. This riddle was sent from an unattended owlery.
    – L.T.Smash
    Commented Jul 20, 2020 at 16:58
  • 1
    I think that the puzzles and riddles are done as worthiness tests, so they would all be removed from your consideration.
    – mpez0
    Commented Jul 20, 2020 at 17:34
  • 9
    Speak friend, and enter.....
    – Alith
    Commented Jul 20, 2020 at 19:48
  • 5
    Does en.wikipedia.org/wiki/Shibboleth#Origin count?
    – msh210
    Commented Jul 22, 2020 at 22:36
  • 6
    The Riddle of the Sphinx? About 1500BC.
    – Chenmunka
    Commented Jul 17, 2021 at 14:53

6 Answers 6


An early fictional example is Jules Verne, Voyage au centre de la Terre (Journey to the Center of the Earth) from 1864.

In this book, the (fictional) 18th century alchemist Arne Saknussemm makes an important discovery and wants to hide it for a while to preserve it. Saknussemm is then killed by the Inquisition, and his books are destroyed. Professor Lidenbrock finds a message from Saknussemm on a slip of paper hidden in a book that wasn't written by Saknussemm, and decodes the weak cryptography protecting the message with his nephew Axel. Lidenbrock assumes that Saknussemm did this to save his discovery from destruction by the Inquisition.

I believe this qualifies for your question. The protagonists are generally educated, but they don't have any special knowledge or connection to Saknussemm. They find and decode the message despite that. They have to break cryptography for this which counts as a puzzle. The Inquisition did not find the hidden message. Saknussem and Lidenbrock both believe that the information about the discovery is valuable and should be protected: Lidenbrock specifically orders Axel to keep the information secret until they can benefit from it.

I believe that this story was influenced by similar real-world examples of 17th century scientists, most famously Galileo in 1610, who used ciphers in their publications with the intention of later proving that they discovered something first, while hiding the actual discovery so that they could benefit from it first.

The later novel La Jangada (1881) by Jules Verne also uses weak cryptography, and may count as another example. In the novel, the terminally-ill criminal Ortega regrets that the protagonist Noam Garral was falsely accused and committed for a diamond robbery that Ortega commited. For reasons unclear to me, he encrypts his confession in a written note that he entrusts to his friend Torrès. He also gives Torrès the key for the encryption, and asks him to deliver the writing to Garral after Ortega's death. Torrès instead blackmails Garral (or so Garral claims) for the writing that would save Garral from further persecution. Eventually Garral's family retrieves the document, and the puzzle-loving judge Jarriquez breaks the encryption, thus proving Garral's innocence.

I will mention for completeness that a third Jules Verne novel, Mathias Sandorf also has information hidden in an encrypted document as a key plot element. This, however, does not seem to be intended as an example in universe, because the only way that the antagonists Zirone and Sarcany manage to get the information is to steal the physical form of the encryption key from the house of the intended recipient.


Lonely Mountain Side-Door is a Puzzle Door (1937))

This answer builds on Alith’s answer, as the question allows not just secret coded doors but puzzle-secured doors as well.

The Side-door or Secret Door was a hidden entrance to the Dwarven kingdom of the Lonely Mountain, located on a shelf of the mountain's western side.

The Hobbit, or There and Back Again predates The Fellowship of the Ring by some 17 years; if the Doors of Durin are arguably the first then the Lonely Mountain Side-Door would be Tolkien’s zeroth puzzle-door.


It seems to me that a very early puzzle-solving situation can be found in Greek mythology with Theseus slaying the minotaur.

The minotaur lived inside a maze/labyrinth and when Theseus went into the maze to kill the minotaur, he took a ball of thread which allowed him to "solve the puzzle" and escape the maze.


This Wikipedia article suggests the story comes from Classical Antiquity, 8th century BC and 6th century AD.

  • Similarly the Sphinx and Oedipus, where the Sphinx required a riddle to be solved to enter/exit the city of Thebes. Commented May 30, 2023 at 13:55

I'm going to add this as an answer, following on from my comment earlier. I'll go with Lord of the Rings - Part 1 The Fellowship of the Ring, originally published in in July 1954.

The particular part that relates to OP's question is chapter called "Into the Dark". In this chapter, Gandalf has reluctantly assented to guiding his companions in the Fellowship through Khazad-dûm (later called Moria).

To enter Khazad-dûm, the party ventures to the West Gate (also called the Doors of Durin). To open the gates, the party needs to answer the riddle carved into them by the builders back in the second age. The riddle is as follows:

The inscription on the archivolt over the Doors read:

"Ennyn Durin Aran Moria. Pedo Mellon a Minno. Im Narvi hain echant. Celebrimbor o Eregion teithant i thiw hin."

As Gandalf first translated it to the other Walkers:

"The Doors of Durin, Lord of Moria. Speak, friend, and enter. I, Narvi, made them. Celebrimbor of Hollin drew these signs."

Initially Gandalf could not find out the password to open them. Merry Brandybuck unknowingly gave Gandalf the answer by asking, "What does it mean by speak, friend, and enter?" When Gandalf realized that the correct translation was "Say friend and enter" he sprang up, laughed, and said "Mellon", which means "friend" in Sindarin, and the Doors opened.

There may be earlier literature that has similar circumstances or situations, (I haven't found any yet) but to my mind the Dwarfs wanted to protect themselves, their riches under the mountain and their trade routes and the inscription over the Doors provides the password reminder to anyone that may of forgotten, this seems to meet the requirements of OP's question.

  • I've been racking my brain on this, and I haven't come up with an earlier example yet either.
    – DavidW
    Commented Jul 22, 2020 at 22:00
  • 11
    It's worth noting that the door wasn't meant to be a puzzle, Gandalf just mistranslated it. The rationale behind the door was that no evil creatures could/would speak Sindarin, so they could put the password right there and not have to worry about enemies using it. Commented Jul 23, 2020 at 0:08

"The Gold Bug" by Edgar Allen Poe from 1843 has a cryptographic riddle which meets the post’s definition. In the story, there is a letter which is written using a substitution cipher, which when decoded, reveals the location of a hidden pirate treasure.

From Wikipedia:

"The Gold-Bug" is a short story by American writer Edgar Allan Poe published in 1843. The plot follows William Legrand, who becomes fixated on an unusual gold-colored bug he has discovered. His servant Jupiter fears that Legrand is going insane and goes to Legrand's friend, an unnamed narrator, who agrees to visit his old friend. Legrand pulls the other two into an adventure after deciphering a secret message that will lead to a buried treasure.

  • Might not count, since by the end of the story it turns out there is nothing supernatural or fantastic at work. Commented May 30, 2023 at 11:31
  • The original poster used the potions puzzle from Harry Potter as an example. Since the potion puzzle is pure logic and could be presented and used without any fantastical or supernatural elements, “The Gold Bug” definitely counts. It is also a true security system with 2 layers in the original short story since figuring out the rest of the message requires the silver to deduce hidden information, which is not the case in either the Riddle of the Sphinx or the Maze of Thesus.
    – Kevonni
    Commented Jun 1, 2023 at 17:52

Another early example is R. Austin Freeman's "The Puzzle Lock" (1929).

An old man has a walk-in vault with a fifteen letter combination.

His reasons for using a puzzle lock are discussed in story.

The nature of the puzzle is

There is a plaque next to the safe with a poem. Add up the roman numerals in the poem (U = V, W = VV), and convert that number to a roman numeral for the combination.

He does not use a key because

he is the leader of a gang of thieves, and could be mugged for the key, but a combination can not be forced.

He does not use a purely memorized key because

he is an old man and does not trust his memory.

  • 2
    Hi, welcome to the site. Do note however that this question isn't asking for early examples in general. It's asking for the single earliest instance. Therefore, it's not really worth submitting a new answer unless it's earlier than the existing answers (which this is not). Commented Dec 30, 2021 at 13:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.