Four-square cipher — encrypt letter pairs with two keyword squares

The four-square cipher arranges four 5×5 squares, two plain and two built from keywords, and encrypts the message two letters at a time by reading across the rectangle they form; enter both keywords to encrypt or decrypt.

Live demo · real result from this tool
Direction
25-letter alphabet

Result

FYGMKYHOBXMFKKKIMD

Processed on your device — nothing is uploaded.

How to use the four-square cipher tool

  1. Choose the Direction: Encrypt or Decrypt.
  2. Enter the First keyword (top right); the default is EXAMPLE.
  3. Enter the Second keyword (bottom left); the default is KEYWORD.
  4. Pick the 25-letter alphabet: Omit Q or Merge I and J.
  5. Type into Your text and copy the Result, which is in capitals without spaces.

What it does and when to use it

Félix Delastelle described the four-square cipher in the early 1900s. Like the Playfair cipher it works on pairs of letters, which hides single-letter frequencies, but it uses two separate keyword squares and has no special rules for letters in the same row or column. Doubled letters need no filler either.

People use it in puzzle hunts, geocaching and cryptography courses as a step beyond Playfair. It is a puzzle and teaching cipher; it does not protect real information. For a single-square cipher by the same inventor, see the bifid cipher. The keyword substitution cipher uses the same keyword-alphabet idea in one line.

How it works

With Omit Q, each square holds the 25 letters A to Z without Q. The plain squares sit top left and bottom right; the keyword squares, each starting with its keyword’s letters and then the rest of the alphabet, sit top right and bottom left:

A B C D E   E X A M P
F G H I J   L B C D F
K L M N O   G H I J K
P R S T U   N O R S T
V W X Y Z   U V W Y Z

K E Y W O   A B C D E
R D A B C   F G H I J
F G H I J   K L M N O
L M N P S   P R S T U
T U V X Z   V W X Y Z

Encrypting a pair. Find the first letter in the top-left square and the second in the bottom-right square. The first cipher letter is in the top-right square, in the first letter’s row and the second letter’s column. The second cipher letter is in the bottom-left square, in the second letter’s row and the first letter’s column.

For HE: H is row 2, column 3; E is row 1, column 5. Top right, row 2, column 5 gives F. Bottom left, row 1, column 3 gives Y. So HE becomes FY.

Decrypting runs the same lookup backwards from the keyword squares to the plain squares. Only letters are used, and an odd count gets an X when encrypting. It all happens in your browser.

Worked examples

Results from the tool:

Help me Obi Wan Kenobi   EXAMPLE / KEYWORD                →  FYGMKYHOBXMFKKKIMD
same message             EXAMPLE / KEYWORD, Merge I and J →  FYNFNEHWBXAFFOKHMD
FYGMKYHOBXMFKKKIMD       EXAMPLE / KEYWORD, Decrypt       →  HELPMEOBIWANKENOBI
Quiz                     EXAMPLE / KEYWORD                →  SCWZ

The first two lines share their opening FY, then part ways because the squares change. The last line shows Quiz losing its Q and gaining a filler X before encryption; the tool adds a warning that one letter Q was removed.

Limits and tips

  • Both keywords must match exactly, and in the right boxes. Swapping them gives a different cipher.
  • Word breaks, digits and punctuation are removed, so plan for the reader to add spaces back.
  • With Omit Q, any Q is dropped and a warning says so. A Q in ciphertext you are decrypting is ignored with a warning, since Omit Q squares never produce one; it usually means the message used Merge I and J.

Frequently asked questions

Which 25-letter alphabet should I choose?
Use the same one as the person you are exchanging messages with. Omit Q, the default, matches the textbook example with EXAMPLE and KEYWORD. Merge I and J is the other common choice and gives a different result for the same message, as the worked examples show.
What happens to the letter Q with Omit Q selected?
It is removed from the message before encrypting, because none of the squares contains it, and a warning under the result says how many Qs were dropped. Quiz is encrypted as UIZ plus a filler X. Spell Q some other way, such as KW, or switch to Merge I and J if your text needs it.
Why does my decrypted text end with an X?
Letters are encrypted in pairs, so an odd-length message gets a filler X before encrypting. Decryption cannot tell it from a real X, so remove it by hand.
How strong is the four-square cipher?
Two independent keywords give it far more possible keys than Playfair, but it is still a classical hand cipher. With enough ciphertext it can be broken by frequency analysis of letter pairs. Use it for puzzles and learning only.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close