Free Tool

Four-Square Cipher Tool

Delastelle's four squares: two plain, two keyed

Ciphertext

How the Four-Square cipher works

Four 5Γ—5 squares sit in a 2Γ—2 block. The top-left and bottom-right squares hold the ordinary alphabet. The top-right and bottom-left squares are each built from a keyword: its letters first, each once, then the rest of the alphabet.

  1. Drop spaces and punctuation and split the message into pairs, adding an X if one letter is left over.
  2. Find the first letter of the pair in the top-left plain square and the second letter in the bottom-right plain square.
  3. They mark opposite corners of a rectangle. The first cipher letter is in the top-right square, on the first letter's row and the second letter's column. The second cipher letter is in the bottom-left square, on the second letter's row and the first letter's column.

To decrypt, find the cipher pair in the two keyed squares and read the other corners from the plain squares.

Example

Keywords EXAMPLE (top right) and KEYWORD (bottom left), Q left out: HELP ME OBI WAN KENOBI becomes FY GM KY HO BX MF KK KI MD.

How to break it

  • Pair frequencies. Each plaintext pair always gives the same cipher pair, so TH, HE and IN show up as the most common cipher pairs. You need a few hundred letters for the counts to mean much.
  • Known words. The first letter of each cipher pair depends only on the first plain letter's row and the second plain letter's column, so a guessed word fills in the keyed squares row by row.
  • Computer search. Hill climbing on the two keyed squares, scored by how English the output looks, breaks a few hundred letters quickly.

History

The French cryptographer FΓ©lix Delastelle (1840–1902) described Four-Square, along with Bifid and Trifid, in his book on cryptography published in 1902, the year he died.

Related tools

Questions

Is Four-Square harder to break than Playfair?

Somewhat. It has no special rules for letters in the same row or column, a pair can contain a doubled letter, and letters can encrypt to themselves, so the clues that give Playfair away are missing. It still falls to pair-frequency analysis given a few hundred letters.

Which squares hold the keywords?

The top-right and bottom-left squares are built from the two keywords. The top-left and bottom-right squares are the plain alphabet and never change.

Why leave out Q instead of joining I and J?

Both make 26 letters fit in 25 cells. Joining I and J is the usual choice; some books and the Wikipedia examples leave out Q instead. Pick whichever the message you are working on used.