Skip to content
100% local

Four-square cipher

Encrypt or decrypt text with the classic Four-square polygraphic substitution cipher.

Input
Output

Four-square cipher

The Four-square cipher is a classical polygraphic substitution cipher invented by Félix Delastelle. It encrypts pairs of letters at a time using four 5x5 (or 6x6) grids arranged in a square: two plain alphabet grids in the top-left and bottom-right, and two grids seeded by your own passwords in the top-right and bottom-left. Paste plaintext to encrypt it, or ciphertext to decrypt it back.

Set a password for the top-right square and a different one for the bottom-left square — each keyword's unique letters fill the grid first, followed by the rest of the alphabet. Choose whether I and J share one cell (the classic 25-letter alphabet) or keep separate cells by switching to the 36-character alphabet, which also adds the ten digits. Pick a filler letter to pad an odd-length message before pairing, and choose whether the result is grouped into two-letter blocks or printed as one continuous run. Turn on "Show cipher squares used" to print all four grids beneath the result, so you can check exactly how each pair was mapped.

Decryption expects an even number of letters — an odd count means a character is missing, and the tool tells you so instead of guessing. Spaces, punctuation and (at 25 letters) digits are dropped from the letter stream rather than encrypted, and accented letters are folded to their plain form before mapping, the same way the classical cipher was used on paper.

Everything runs locally in your browser — passwords and text are never uploaded anywhere. Copy the result, download it as a .txt file, or send the output straight back into the input to encrypt or decrypt another round.

FAQ

How is the Four-square cipher different from Playfair?
Playfair uses one keyed grid and shifts rows or columns depending on how a pair lines up. Four-square uses two plain grids and two separately keyed grids, and always swaps one letter from each pair between them — there is no special case for a repeated letter.
Why are there two passwords?
Each password seeds one of the two cipher squares (top-right and bottom-left). Using two different passwords, rather than one repeated, is what makes the classic version of this cipher stronger.
What happens to spaces, numbers and punctuation?
They are removed from the letter stream before encryption. At the 36-character alphabet setting, digits are kept and encrypted like any other character.
Why did decryption fail with an error?
Ciphertext must contain an even number of letters, since the cipher always works on pairs. An odd count usually means a character was dropped when the ciphertext was copied.
Is my text or password uploaded anywhere?
No. Encryption and decryption run entirely in your browser — your text and passwords never leave your device.