Four-Square Cipher Online Encoder

The Four Square cipher uses four 5x5 matrices to encrypt pairs of letters into different letter pairs. Invented by Félix Delastelle in 1902, this polygraphic substitution cipher splits plaintext into digraphs and transforms them through two keyword-based grids, offering stronger security than Playfair. Use this free tool to encode and decode Four Square cipher messages instantly with custom keywords.

“HELLO”“FKIYFR”(EXAMPLE + KEYWORD)
Result
0 characters
Key 1:
Key 2:
Alphabet Mode:
(J → I)

Four-Square Cipher Layout

Plaintext
Ciphertext

Plaintext 1 (Top-Left)

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

Cipher 1 (Top-Right)

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

Cipher 2 (Bottom-Left)

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

Plaintext 2 (Bottom-Right)

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

Four-Square uses four 5×5 matrices arranged in a square pattern

Encryption: Find plaintext letters in diagonal squares (blue), read ciphertext from opposite corners (green)

Explore More Tools

Frequently Asked Questions

What is the Four Square cipher?

The Four Square cipher is a polygraphic substitution cipher that encrypts pairs of letters using four 5x5 matrices arranged in a square grid. Invented by Félix Delastelle around 1902, it improves on simpler ciphers by using two independent keyword-based alphabets for encryption, making frequency analysis significantly harder than single-substitution methods.

How does the Four Square cipher encrypt text?

The Four Square cipher encrypts text by splitting it into pairs of letters (digraphs). Each pair is located in two plaintext grids (top-left and bottom-right), and the corresponding ciphertext letters are read from the opposite corners in the two keyword grids (top-right and bottom-left). This rectangle-based lookup transforms each letter pair into a different encrypted pair.

Who invented the Four Square cipher?

Félix Delastelle, a French cryptographer, invented the Four Square cipher around 1902. He is also known for creating the Bifid and Trifid ciphers. Delastelle's work focused on polygraphic substitution methods that encrypt multiple letters at once, providing stronger security than monoalphabetic ciphers common at the time.

How is Four Square different from Playfair cipher?

Four Square uses four 5x5 matrices with two independent keywords, while Playfair uses only a single 5x5 matrix with one keyword. This means Four Square has a vastly larger keyspace and can encrypt repeated letter pairs like LL without requiring special rules, unlike Playfair which must separate identical letters with a filler character.

How do you set up the four matrices?

You arrange four 5x5 grids in a 2x2 pattern. The top-left and bottom-right grids contain the standard alphabet (with I and J merged into one cell). The top-right grid is filled using the first keyword followed by remaining unused letters, and the bottom-left grid is filled using the second keyword the same way. Each keyword letter appears only once.

Is the Four Square cipher secure?

The Four Square cipher is more secure than most classical ciphers due to its dual-keyword system and large keyspace of approximately (25!)² combinations. However, it is not secure by modern standards. With enough ciphertext, frequency analysis of digraphs and known-plaintext attacks can break it. It remains valuable as an educational tool for understanding polygraphic encryption.

How do you decrypt a Four Square cipher?

Decryption reverses the encryption process. Split the ciphertext into letter pairs, locate each pair in the two keyword grids (top-right and bottom-left), then read the plaintext letters from the opposite corners in the standard alphabet grids (top-left and bottom-right). You must know both keywords to reconstruct the keyed grids and recover the original message.

What is the Four-Square Cipher?

The four-square cipher is a digraphic substitution cipher invented by French cryptographer Felix Delastelle in 1902. It encrypts pairs of letters (digraphs) using four 5x5 matrices arranged in a square pattern, with two independent keywords generating the cipher alphabets. This dual-key structure makes it significantly more secure than its predecessor, the Playfair cipher, which relies on a single keyword and a single matrix.

The cipher was used for military field communications during World War I and World War II, where it provided a practical balance between security and ease of manual implementation. Today it remains an excellent tool for studying digraphic encryption and understanding how multi-key systems resist cryptanalysis.

How Does the Four-Square Cipher Work?

The encryption system uses four 5x5 grids arranged in a 2x2 layout:

  • Top-left and bottom-right: Standard alphabets in normal order (plaintext squares)
  • Top-right and bottom-left: Keyword-generated scrambled alphabets (cipher squares)

Since each grid has only 25 cells, the letters I and J are typically merged into a single character.

Encryption Process

  1. Prepare the message: Remove non-alphabetic characters, convert to uppercase, and split the text into pairs of letters (digraphs). Add padding if the message has an odd number of letters.
  2. Locate the first letter of each pair in the top-left plaintext matrix, and the second letter in the bottom-right plaintext matrix.
  3. Form a rectangle across all four matrices using these two positions as opposite corners.
  4. Read the ciphertext from the remaining two corners: the first cipher letter comes from the top-right matrix (same row as the first plaintext letter, same column as the second), and the second from the bottom-left matrix (same row as the second plaintext letter, same column as the first).

This rectangular substitution means each letter pair transforms as a unit, disrupting the single-letter frequency patterns that break simpler ciphers.

Worked Example

With keywords "EXAMPLE" and "KEYWORD", encrypting the digraph "HE":

  1. Find H in the top-left matrix (row 1, col 2)
  2. Find E in the bottom-right matrix (row 0, col 4)
  3. Read the top-right matrix at (row 1, col 4) and bottom-left matrix at (row 0, col 2)
  4. The encrypted digraph replaces "HE" with the letters found at those positions

Four-Square Cipher vs Playfair and Other Digraph Ciphers

FeatureFour-Square CipherPlayfair CipherHill CipherPolybius Square
Matrices used4 (two keyed, two plain)1 (keyed)Key matrix (nxn)1 (fixed grid)
Keys required2 independent keywords1 keywordMatrix of numbersNone (fixed encoding)
Unit of encryptionLetter pairs (digraphs)Letter pairs (digraphs)Blocks of n lettersSingle letters
Reversed digraph weaknessNoYes (AB and BA related)NoN/A
Key spaceLarge (two independent keywords)Moderate (one keyword)Very large (matrix entries)None

The four-square cipher's main advantage over Playfair is eliminating the reversed digraph vulnerability. In Playfair, encrypting AB produces a result mathematically related to encrypting BA, which gives cryptanalysts a useful pattern to exploit. The four-square design avoids this entirely.

How to Use This Tool

  1. Enter two keywords to generate the cipher matrices. Choose unrelated words to maximize security.
  2. Type your message in the input field. The tool handles text preparation (uppercase conversion, I/J merging, padding) automatically.
  3. View the four matrices displayed interactively to understand how your keywords generate the encryption environment.
  4. Copy the result with one click.

Switch between encryption and decryption modes using the mode selector. The same two keywords decrypt the message by reversing the rectangular substitution.

Frequently Asked Questions

How does the four-square cipher differ from a two-square cipher?

The two-square cipher uses only two matrices (one keyed, one plain), processing digraphs through a simpler rectangular substitution. The four-square cipher doubles the number of matrices and uses two independent keywords, producing a multiplicatively larger key space and eliminating certain structural weaknesses present in the two-square design.

Can the four-square cipher be cracked without keys?

Yes, using modern computational methods. Dictionary attacks test common word combinations as potential keywords, and digraph frequency analysis can reveal statistical patterns in longer ciphertexts. However, the dual-key structure makes it significantly harder to break than single-key ciphers like Playfair. See our Four-Square Decoder for automated cryptanalysis.

Why are I and J merged in the matrix?

A 5x5 grid holds 25 characters, but the English alphabet has 26 letters. Merging I and J is the most common solution, since they are visually similar and rarely cause ambiguity in decrypted text. Some implementations merge other pairs or use a 6x6 grid with digits instead.

Is the four-square cipher secure for modern use?

No. While it was a strong manual cipher in its era, modern computers can test keyword combinations rapidly and break it through statistical analysis. It is best suited for educational purposes and understanding classical cryptographic principles. For real security, use modern algorithms like AES.

What makes a good keyword pair?

Choose two unrelated words that are reasonably long (6+ characters) and avoid dictionary words that are too common. The keywords should not share many letters with each other, as overlapping characters reduce the effective key space. Avoid using the same keyword for both matrices.