The Foursquare Cipher is a classical polygraphic substitution cipher invented by Félix Delastelle around 1902. It encrypts text two letters at a time (digraphs) using four 5×5 letter squares arranged in a larger square formation. By operating on pairs of letters instead of single characters, it significantly complicates frequency analysis compared to simple monoalphabetic systems.

Two of the squares contain the standard alphabet (with I/J combined to fit 25 letters), while the other two are constructed using chosen keywords. Encryption works by forming a rectangle between letters located in opposite standard squares and substituting the corresponding letters from the keyed squares.

Foursquare Cipher: Grid Setup

The cipher uses four 5×5 grids arranged as follows. In this example, the keywords KEYWORD and SECRET generate the top-right and bottom-left squares respectively.

Top-Left (Standard)         Top-Right (Keyed: "KEYWORD")

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

Bottom-Left (Keyed: "SECRET")    Bottom-Right (Standard)

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

Foursquare Cipher: Encoding

To encrypt a message, divide the plaintext into digraphs. If the message contains an odd number of letters, append a filler character such as X. For each pair:

• Locate the first letter in the top-left standard square.
• Locate the second letter in the bottom-right standard square.
• Form a rectangle using their row and column positions.
• The encrypted pair is formed by taking: – the letter from the top-right keyed square at the first letter’s row and second letter’s column
– the letter from the bottom-left keyed square at the second letter’s row and first letter’s column

Plaintext: HELLO
Split into digraphs: HE  LL  OX
(X added because of odd length)

HE:
H (Top-Left) → Row 2, Col 3
E (Bottom-Right) → Row 1, Col 5

Cipher 1 → Top-Right (Row 2, Col 5) = C
Cipher 2 → Bottom-Left (Row 1, Col 3) = C

HE → CC

LL:
L (Top-Left) → Row 3, Col 1
L (Bottom-Right) → Row 3, Col 1

Cipher 1 → Top-Right (Row 3, Col 1) = F
Cipher 2 → Bottom-Left (Row 3, Col 1) = H

LL → FH

OX:
O (Top-Left) → Row 3, Col 4
X (Bottom-Right) → Row 5, Col 3

Cipher 1 → Top-Right (Row 3, Col 3) = H
Cipher 2 → Bottom-Left (Row 5, Col 4) = Y

OX → HY

Ciphertext: CC FH HY

Notice how each digraph forms the corners of a rectangle spanning the four squares. The substitution always occurs across the keyed grids, never within the standard ones.

Foursquare Cipher: Decoding

Decryption reverses the rectangle process. For each ciphertext pair:

• Locate the first letter in the top-right keyed square.
• Locate the second letter in the bottom-left keyed square.
• Use their positions to reconstruct the original rectangle.
• Recover: – the letter from the top-left standard square at the first letter’s row and second letter’s column
– the letter from the bottom-right standard square at the second letter’s row and first letter’s column

Ciphertext: CC FH HY
Split into digraphs: CC  FH  HY

CC:
C (Top-Right) → Row 2, Col 5
C (Bottom-Left) → Row 1, Col 3

Plain 1 → Top-Left (Row 2, Col 3) = H
Plain 2 → Bottom-Right (Row 1, Col 5) = E

CC → HE

FH:
F (Top-Right) → Row 3, Col 1
H (Bottom-Left) → Row 3, Col 1

Plain 1 → Top-Left (Row 3, Col 1) = L
Plain 2 → Bottom-Right (Row 3, Col 1) = L

FH → LL

HY:
H (Top-Right) → Row 3, Col 3
Y (Bottom-Left) → Row 5, Col 4

Plain 1 → Top-Left (Row 3, Col 4) = O
Plain 2 → Bottom-Right (Row 5, Col 3) = X

HY → OX

Recovered Plaintext: HELLOX
(Remove filler X if needed)

Foursquare Cipher: Notes

The Foursquare Cipher represents an elegant evolution in classical cryptography. By combining digraph substitution with keyed grids, Delastelle increased resistance to basic statistical attacks while maintaining mechanical simplicity. Although modern cryptanalysis easily breaks it, the cipher demonstrates a clever geometric approach to encryption and highlights the transition from monoalphabetic to more sophisticated polygraphic systems.

Foursquare Cipher