Ciphers

Classical ciphers

Caesar to Enigma. Letters in and letters out. Every choice that makes a puzzle answer reproducible is written down.

The pen and paper half of the library, plus one machine. They work on letters A to Z and leave everything else where it was, so a sentence keeps its spaces and its commas and still reads like a sentence after encoding. Great for riddles, lessons and CTFs. Useless for anything you actually want to keep secret, and that's fine, it's not what they're here for.

ciphers ciphers --category classical20 ciphers · registry order
OptionsKeyspace
Caesar CiphercaesarShiftshift?25
ROT-13rot13Shiftnone1
ROT-47rot47Shiftnone1
AtbashatbashReflectionnone0
VigenèrevigenerePolyalphabetickey26^keyLength
BeaufortbeaufortPolyalphabetickey26^keyLength
AutokeyautokeyPolyalphabetickey26^keyLength
TrithemiustrithemiusPolyalphabeticnonefixed
AlbertialbertiPolyalphabetickey, periodnot stated
Rail Fencerail-fenceTranspositionrails?~n
Affine CipheraffineMultiplicativea?, b?12 × 26 = 312
PlayfairplayfairDigraphkey25! ≈ 1.5×10²⁵
Polybius SquarepolybiusFractionationkey?1
Morse CodemorseFractionationnone1
Bacon's CipherbaconFractionationletters?2
Tap Codetap-codeFractionationnone1
Columnar TranspositioncolumnarTranspositionkeyn!
ADFGVXadfgvxFractionationkey?, transposition?36! grids × n! column orders
Bifid CipherbifidFractionationkey?, period?25! × period variants
Enigma M3enigmaRotorpositions?, rings?, plugboard?26^6 × plugboard configurations
read from the registry in your browser / no networka name with ? is optional

Conventions they share

  • Latin alphabets are A to Z. Digits, punctuation, emoji and non-Latin letters pass through untouched unless stripNonAlpha is set, and they never advance a key.
  • preserveCase is on by default. Lowercase in, lowercase out.
  • Playfair, Polybius and Bifid fold J into I. Tap code shares C and K. Bacon uses 26 letters unless letters: 24 asks for his own table. Enigma is the Wehrmacht M3 with rotors I, II, III and reflector B.
  • Shift 0, one rail, a multiplier sharing a factor with 26. An option that would make the cipher an identity or break the bijection is an error before the first letter. No silent pass.

Families

Shift adds a constant to every letter. Reflection mirrors the alphabet. Multiplicative multiplies and adds modulo 26. Polyalphabetic changes the shift as it goes, by keyword, by position or by turning a disk. Digraph works on pairs. Fractionation breaks a letter into coordinates or symbols and, in Bifid and ADFGVX, shuffles the pieces. Transposition moves letters without changing a single one. Rotor has one member, and that one has enough settings for the rest of the list combined.

Where to start

Stuck on a puzzle? Count the letters first. A histogram that still looks like English means one alphabet, maybe shifted, and a Caesar brute force takes a second. A flat one means a key that changes as it goes, so the Vigenère family is the next stop.