Four-Square Cipher

Four squares
Plain square
ABCDE
FGHIK
LMNOP
QRSTU
VWXYZ
Keyword 1
EXAMP
LBCDF
GHIKN
OQRST
UVWYZ
Keyword 2
KEYWO
RDABC
FGHIL
MNPQS
TUVXZ
Plain square
ABCDE
FGHIK
LMNOP
QRSTU
VWXYZ
FYNFNEHWBXAFFOKHMD
Transformed locally in your browser. The two keywords build the upper-right and lower-left squares (J merged into I); the upper-left and lower-right squares hold the plain A–Z alphabet. The message is normalized to uppercase A–Z — spaces, digits, and punctuation are dropped — then split into letter pairs, padding an odd length with a trailing X. Each plaintext pair is located in the two plain squares and rewritten through the two keyword squares (decoding reverses the mapping). Output is always uppercase A–Z, so case, digits, and symbols are not preserved, and the I/J merge plus any X filler remain in decoded text.

Encode digraphs through two keyword squares

The four-square cipher encrypts pairs of letters. For each plaintext pair, the first letter is found in the upper-left plain square and the second in the lower-right plain square; the ciphertext reads the upper-right square at the first letter's row and second letter's column, then the lower-left square at the second letter's row and first letter's column. Two keyword squares make it stronger than Playfair, which keys a single square.

When to use this tool

Reach for the four-square cipher when a puzzle, CTF challenge, escape room, or cryptography lesson encrypts letter pairs through two keyword squares. Described by Félix Delastelle and a close relative of Playfair, it spreads each digraph across four 5×5 squares — two plain and two keyed — so a single keyword square is no longer enough to read the message. It sits naturally beside the Playfair and Bifid tools, rounding out the digraph and square family of classical ciphers here.

Privacy and limitations

Everything runs locally in your browser; nothing is sent anywhere. This is a classical cipher, not real encryption — two known keywords make it trivial to reverse. Every square merges J into I, so I and J share one cell and both decode back to I; encoding is case-insensitive and drops every non-letter before pairing. Output is uppercase letters only, an odd-length message is padded with a trailing X, and original case, spacing, and punctuation are not recovered — a round-trip returns the cleaned, uppercased message (with any padding) rather than your exact input. Both keywords are optional; an empty keyword yields the plain A–Z square. Use the encode/decode toggle to switch directions, since the transform is not self-inverse.