The Two Square Cipher is a polygraphic substitution cipher that uses two separate 5x5 squares to encrypt pairs of letters. It is a variant of the Playfair Cipher but uses two grids instead of one, providing a more complex substitution for digraphs (pairs of letters). This cipher increases security by avoiding simple frequency analysis that single-letter substitution ciphers are vulnerable to.

To construct a Two Square Cipher, you prepare two 5x5 matrices (squares), each containing a permutation of the alphabet (typically I/J are combined to fit 25 letters). One square is used for the first letter of a digraph and the other for the second letter. Encryption rules map the positions of the letters in the squares to produce ciphertext digraphs, usually forming a rectangle and swapping the letters according to their row and column positions.

Two Square Cipher: Encoding

Using the key squares MONARCHY and KEYWORD, the plaintext HELLO can be encrypted as follows:

Plaintext digraphs: HE LL LO
Ciphertext digraphs: OD TF AU
Ciphertext: ODTFAU

Each pair of letters is located in the respective squares, forming a rectangle, and the letters are substituted with the opposite corners of that rectangle.

Two Square Cipher: Decoding

Decoding reverses the process by locating each ciphertext digraph in the squares and swapping them back to recover the original plaintext:

Ciphertext digraphs: OD TF AU
Locate letters in key squares and swap corners:
Plaintext digraphs: HE LL LO
Plaintext: HELLO

Two Square Cipher: Notes

The security of the Two Square Cipher relies on the secrecy and randomness of the two key squares. It is more resistant to frequency analysis than single-letter substitution ciphers, especially for longer texts. Like Playfair, digraph ciphers are primarily of historical interest today but provide excellent examples of polygraphic substitution techniques. - Proper handling of I/J merging and repeated letters in digraphs is necessary to ensure consistent encoding and decoding.

Two-Square Cipher

T
🗝
🗝