Foursquare Cipher

What is the Foursquare Cipher?

In the foursquare cipher, four 5x5 Polybius squares are arranged to form a 25x25 grid. The top left and bottom right Polybius squares are unkeyed. The other two are keyed, each using a unique key, and can use alternate routes.

The plaintext is written in groups of two. The first in a pair is found in the top left Polybius square, and the second in the pair is found in the bottom right Polybius square. The plaintext letters are used as coordinates for finding the first letter of the ciphertext pair in the top-right square and the second letter of the ciphertext pair in the bottom-left square.

Example

Keyword 1: KAATSKILL
Keyword 2: MOUNTAINS


ABCDE KLFOV
FGHIK ABGPW
LMNOP TCHQX
QRSTU SDMRY
VWXYZ IENUZ

MADKV ABCDE
OIELW FGHIK
USFPX LMNOP
NBGQY QRSTU
TCHRZ VWXYZ

Plaintext: RIP VAN WINKLE

Encipher step:
RI PV AN WI NK LE
RI TZ FU UI XE XM

Ciphertext: RITZF UUIXE XM