Four-Square Cipher Encrypt & Decrypt

Digraph cipher using four interlocking Polybius squares.

Free Four-square cipher tool that encrypts and decrypts letter pairs across four 5×5 grids — two keyed and two plain. Implements the real corner-swap rule with I/J merging, in your browser. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

How does the Four-square cipher work?

Four 5×5 squares are arranged in a 2×2 block: plain alphabets top-left and bottom-right, and two keyword squares top-right and bottom-left. Each plaintext pair is located in the two plain squares, and the cipher letters are read from the opposite corners in the keyed squares.

The Four-square cipher, invented by Félix Delastelle in the late 1800s, is a digraph substitution cipher that encrypts pairs of letters using four 5×5 grids. Two of the grids hold keyword alphabets and two hold the plain alphabet, arranged in a 2×2 block. Using two separate keys makes it noticeably stronger than the single-square Playfair cipher. This tool builds the squares and applies the real rules in your browser.

How it works

Arrange four 5×5 squares in a block. The top-left and bottom-right squares hold the plain alphabet (I and J merged). The top-right square is keyed with keyword 1 and the bottom-left square is keyed with keyword 2.

Split the plaintext into pairs, padding a final lone letter with X. For each pair, find the first letter in the top-left plain square and the second letter in the bottom-right plain square. The two ciphertext letters are taken from the opposite corners of the rectangle they form: the first comes from the top-right keyed square at (row of letter 1, column of letter 2), and the second from the bottom-left keyed square at (row of letter 2, column of letter 1).

Decryption simply reverses the lookup: locate the ciphertext letters in the two keyed squares and read the plaintext pair from the corresponding cells of the two plain squares.

Example

With keyword 1 EXAMPLE and keyword 2 KEYWORD, the plaintext pair HE encrypts to FY: H sits at row 1, column 2 of the plain square and E at row 0, column 4, so the cipher letters are the top-right square’s cell (1, 4) and the bottom-left square’s cell (0, 2).

Notes

Because each square can be keyed independently, the Four-square cipher does not suffer Playfair’s reversible-pair weakness, and identical letters in a pair encrypt cleanly without an inserted X. Decrypted text may still contain a trailing padding X or an I that should be read as J.