What is a classical cipher?

Classical ciphers are the pen-and-paper ciphers used before computers, from ancient Hebrew scribes to telegraph clerks. Each one hides a message by swapping its letters for others (a substitution cipher), by moving them around (a transposition cipher), or by writing them as numbers or symbols. They're easy to break today, so they don't keep real secrets, but they're a favorite of escape rooms, geocaches, puzzle hunts, school lessons and secret notes.

Tool description

Type or paste a message into the Plain text box, pick a cipher from the Cipher menu and set its key below it, and the cipher text appears in the Cipher text box as you type, ready to copy. The Cipher Encoder starts on Atbash, and every cipher also has an encoder of its own that starts on it, such as the Playfair Cipher Encoder. Ciphers without a key say Not needed in the Key field. The keyword starts empty: until you type one, columnar transposition and Beaufort ask for it, and Playfair uses the alphabet in order. Insert sample fills in See you at the park at noon with the keyword PICNIC, 3 rails, multiplier 5 and shift 8. To read a message back, press the swap button between the boxes, which also moves the result into the input, or use the Cipher Decoder or your cipher's own decoder, such as the Playfair Cipher Decoder. Everything runs in your browser.

Ciphers

Cipher Key How it works
Atbash None Reverses the alphabet: A becomes Z, B becomes Y, and so on
A1Z26 None Writes each letter as its place in the alphabet, A = 1 to Z = 26, as in 8-9
Affine Multiplier (a) and shift (b) Turns each letter's number x, with A = 0, into a × x + b, counted around the alphabet
Rail fence Number of rails Writes the text in a zigzag over the rails, then reads it rail by rail
Columnar transposition Keyword Writes the text in rows under the keyword, then reads the columns in the keyword's ABC order
Beaufort Keyword Subtracts each letter from the next letter of the keyword
Playfair Keyword Encodes pairs of letters by their places in a 5 × 5 square that starts with the keyword
Polybius square None Writes each letter as its row and column in a 5 × 5 square, as in 23 for H
Baconian 26 letters, or Bacon's own 24 Writes each letter as five A's and B's, as in AABBB for H

Examples

See you at the park at noon, with the keys Insert sample sets:

  • Atbash: Hvv blf zg gsv kzip zg mllm
  • Affine, multiplier 5 and shift 8: Ucc yae iz zrc fipg iz vaav
  • Rail fence, 3 rails: Sot atn ey uth pran oe aeko
  • Playfair, keyword PICNIC: XL FX UZ NU QM BC IU OI YF LZ MA
  • Polybius square: 431515 543445 1144 442315 35114225 1144 33343433

What happens to spaces, case and punctuation

  • Atbash, affine and Beaufort change only the letters A to Z and keep their case, so spaces, digits and punctuation stay as they are. The Beaufort keyword moves on with each letter, not with spaces.
  • Rail fence and columnar transposition move the letters and digits and leave spaces and punctuation where they were, so the words keep their lengths. Accented letters and letters of other alphabets move as they are.
  • A1Z26 and Polybius square write each letter as a number and keep everything else, digits included. A1Z26 joins the numbers of a word with hyphens, and the Polybius square writes its pairs side by side.
  • Playfair uses letters only, counts J as I and writes upper-case pairs. An X goes between two same letters that would share a pair, and after a last letter left on its own (a Q when that letter is X), so Hello is split into the pairs HE LX LO before it is encoded.
  • Baconian uses letters only and writes each one as a group of five A's and B's. In Bacon's 24-letter alphabet, I and J share a code, and so do U and V.
  • Outside the transpositions, accented letters count as their base letters, so é is encoded like e. Letters of other alphabets, such as Cyrillic or Greek, stay as they are, or are left out by Playfair and Baconian.

Tips

  • For the affine cipher, the multiplier has to share no factor with 26, which is why the list offers only 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23 and 25. With a multiplier of 1, it's a Caesar cipher.
  • The Caesar, Vigenère and ROT ciphers have tools of their own, the Caesar Cipher Encoder, the Vigenere Cipher Encoder and the ROT Cipher Encoder, and the pigpen cipher, written in symbols, has the Pigpen Cipher Translator.