📖 Cipher

An algorithm to encrypt a stream of information

A cipher is an algorithm which encrypts and decrypts information. We can think of the information as text, or perhaps the bytes of a computer file. For a puzzle piece, text is generally more common, but certain computer games may include encrypted binary data.

With ciphers, we can talk about plain text and cipher text. The plain text is the readable message without the cipher applied. The cipher text is the message once the algorithm has been applied. These terms apply even if we're talking about binary data, such as an image. The typical game mechanic is for a player to recover the plain text from cipher text, revealing a message for them to progress in the game.

Generally we assume a key is required for the cipher to function. Without a key there is no way to decrypt a piece of text. For games however, we choose to have trivial keys, or no key at all. Real-world ciphers are not interesting in games since they are unbreakable, whereas most ciphers used in puzzles are trivially crackable in the real-world.

Substitution Cipher

Substitution ciphers are fairly common. These are a simple mapping between characters. For example, a ROT13 cipher uses a character in the alphabet that is 13 steps away form the original.

  • Plain Text: Cipher puzzles are fun!
  • ROT13 cipher text: Pvcure chmmyrf ner sha!

The 13 steps are determined by taking the position of the number in the alphabet and counting 13 letters further. For example, C is the 3rd letter of the alphabet, plus 13 is the 16th letter, which is a P. Numbers above 26 wrap back to 1, so R becomes E.

ROT13 doesn't have a key; it is fixed substitution. The Caeser cipher however has a key, which specifies how many steps to move in the alphabet. ROT13 is thus a Caeser cipher with a key of 13.

Cipher Wheel

A common puzzle piece is the cipher wheel. These are two overlapping discs that have letters on the inner and outer ring. The inner ring can be rotated to provide a different alignment with the outer ring. The player usually needs to find out which rotation is correct then apply the substitution cipher.

One-to-One

A cipher is generally a one-to-one mapping between characters in the plain text and characters in the cipher text. This distinguishes it from an encoding where the mapping may vary significantly in size and form.

Though most ciphers remain in one alphabet, they can also cross alphabets. For example, we can replace roman letters "ABC…" with runes "ᚠᚡᚢ…". This can be done whether or not a key is used, though in a game, having both an alphabet change and a key would make for a challenging puzzle.

In real-world encryption, cross-alphabet ciphers add no value, since they'll both simply be converted to an equivalent numeric representation "123…". In games, cross-alphabet ciphers can introduce a thematic pseudo-lingual quality.

Feedback on Working Draft

If you have any questions, need an example, or want clarification, then let me know. Ask on Discord or Twitter.

Assume everything in this reference is a working draft, there's prone to be some mistakes and inconsistencies. I figure it's best to publish and get feedback rather than write for years in secret. The terms will change, the structure will shift, and the bugs will be chased out. It'll take a while.