Play n Tools

Free tools & games for everyone

Free · No sign-up · No accounts

Classical cipher lab

Encrypt and decrypt with eleven historical ciphers, from Caesar and ROT13 to Vigenère and Playfair, and crack secret messages with letter statistics.

How to use

  1. Encrypt & decrypt: pick a cipher, set its key (a shift, two numbers, a key word or a number of rails), type your message and press Encrypt. Paste a secret message and press Decrypt to read it with the same key.
  2. For Playfair, Polybius and keyword substitution the key square or alphabet is drawn above the message, so you can check your pencil-and-paper working against it.
  3. Crack a message: paste a message made with a Caesar, affine or Vigenère cipher and press Crack it. Every possible key is tried and ranked by how English the result looks.
  4. Letter frequencies: paste any text to count each letter and compare it with normal English. This is the first step code breakers have used for over a thousand years.

Keyboard and touch

TabMove between tabs, boxes and buttons
Enter or Space on a tab or buttonOpen the tab or press the button
Arrow keys in a number boxChange the shift, a, b or rails by one
Typing in the frequency boxUpdates the counts as you type

Tips

  • ROT13 is a Caesar shift of 13; because 13 + 13 = 26, the same button both hides and reveals the text.
  • A Caesar or substitution cipher keeps the letter frequencies of the language: the most common letter in a long English secret is usually E, then T, A and O.
  • Vigenère hides frequencies by using several shifts, but every letter at the same place in the key uses the same shift. Find the key length and each column falls like a Caesar cipher. Longer messages crack more reliably; under about 100 letters the guess may be wrong.
  • Transposition ciphers (rail fence, columnar) only move letters around, so their letter counts look exactly like English. That is a quick way to tell them apart from substitution ciphers.
  • None of these ciphers is safe for real secrets today. For real files use the Text & file encryptor, which uses modern AES encryption.

About this lab

Caesar shifts each letter a fixed number of places; atbash reverses the alphabet; affine maps letter number x to (a x + b) mod 26, where a must have an inverse mod 26. Keyword substitution writes the key word (repeats dropped) followed by the unused letters as the cipher alphabet. Vigenère adds the key letters in turn (A = 0); Beaufort subtracts the message from the key, so it undoes itself; autokey starts with the key word and then continues with the message itself. Only letters use up key letters; other characters pass through.

The Polybius square and Playfair use a 5 × 5 square built from the key word, with I and J sharing a square. Playfair splits the message into pairs, puts X between doubled letters (Q between two Xs) and pads an odd last letter with X; a pair in one row moves right, in one column moves down, otherwise it swaps columns. Rail fence writes the letters in a zigzag over the rails and reads row by row. Columnar transposition writes the letters in rows under the key word and reads the columns in alphabetical order of the key letters (equal letters left to right), with no padding.

Cracking scores every candidate with the chi-squared distance between its letter counts and English letter frequencies (Lewand, 2000). For Vigenère the key length is the shortest length whose columns reach at least 90 % of the best average index of coincidence (Friedman, 1922); each column is then solved as a Caesar shift. Everything runs in your browser; nothing you type is sent anywhere.

See you tomorrow!

A fresh daily puzzle every morning, and new tools added every month.

Browse every product