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 classical40 ciphers · registry order
OptionsKeyspace
Caesar CiphercaesarShiftshift?25
ROT-13rot13Shiftnone1
ROT-47rot47Shiftnone1
AtbashatbashReflectionnone0
SubstitutionsubstitutionMixed alphabetkey26!
VigenèrevigenerePolyalphabetickey26^keyLength
GronsfeldgronsfeldPolyalphabetickey10^keyLength
BeaufortbeaufortPolyalphabetickey26^keyLength
PortaportaPolyalphabetickey, rotation?13^keyLength
AutokeyautokeyPolyalphabetickey26^keyLength
Running keyrunning-keyPolyalphabetickey26^textLength
TrithemiustrithemiusPolyalphabeticnonefixed
AlbertialbertiPolyalphabetickey, periodnot stated
Quagmire Iquagmire-1Polyalphabetickey, indicator, indicatorUnder?26! × 26^indicatorLength
Quagmire IIquagmire-2Polyalphabetickey, indicator, indicatorUnder?26! × 26^indicatorLength
Quagmire IIIquagmire-3Polyalphabetickey, indicator, indicatorUnder?26! × 26^indicatorLength
Quagmire IVquagmire-4Polyalphabetickey, secondKey, indicator, indicatorUnder?(26!)² × 26^indicatorLength
ChaocipherchaocipherPolyalphabetickey, secondKey26! × 25!
Rail Fencerail-fenceTranspositionrails?~n
Affine CipheraffineMultiplicativea?, b?12 × 26 = 312
PlayfairplayfairDigraphkey25! ≈ 1.5×10²⁵
Four-squarefour-squareDigraphkey, secondKey, omit?(25!)² ≈ 2.4×10⁵⁰
Two-squaretwo-squareDigraphkey, secondKey, orientation?, omit?(25!)² ≈ 2.4×10⁵⁰
HillhillPolygraphickey, alphabet?157,248
Polybius SquarepolybiusFractionationkey?, alphabet?1
NihilistnihilistFractionationkey, square?25! squares times 25^n keys of n letters
Morse CodemorseFractionationnone1
Fractionated Morsefractionated-morseFractionationkey26!
Bacon's CipherbaconFractionationletters?, lowercase?2
Tap Codetap-codeFractionationnone1
A1Z26a1z26Fractionationseparator?, zero?1, or 17 in the single digit form
Book CipherbookHomophonicbook, address?, pick?, start?every text both sides have
Columnar TranspositioncolumnarTranspositionkeyn!
Route TranspositionrouteTranspositionwidth, corner?, path?~20n
ADFGVXadfgvxFractionationkey?, transposition?36! grids × n! column orders
Bifid CipherbifidFractionationkey?, alphabet?, period?25! × period variants, 36! on a 6×6
Trifid CiphertrifidFractionationkey?, period?, symbol?26! × period variants
Straddling Checkerboardstraddling-checkerboardFractionationkey?, blanks?28! boards × 90 ordered pairs of blanks
TridigitaltridigitalMixed alphabetkey, secondKey10! digit orders × 26! alphabets
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 or a Hill matrix with no inverse. 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. Mixed alphabet shuffles the whole thing. By keyword or by hand. 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. Polygraphic runs a whole block through a matrix, so one letter changes all of it. Fractionation breaks a letter into coordinates or symbols and, in Bifid and ADFGVX, shuffles the pieces. Nihilist adds a key to them instead. 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.