Four Square

History

The Four Square cipher was described by Helen Fouché Gaines (1888-1940) on page 199 of her book Cryptanalysis: A Study of Ciphers and Their Solution, first published as Elementary Cryptanalysis, 1939 though no name was attributed to it. It was first given its name in 1943 by Major Donald D Millikin in his book Elementary Cryptography and Cryptanalysis who referred to it as the "Four Square Matrix Cipher". As its name implies it consists of four polybius squares, two of which are straight alphabets positioned in the top left and bottom right corners of the group and the others keyed alphabets in the other two corners forming a 10 x 10 matrix.

Description

To encipher text using the Four Square cipher the two keyed 5 x 5 square matrices are created and filled with different keyed alphabets using all the letters of the alphabet, with J being replaced by I. These are positioned in the top right and bottom left corners of the 10 x 10 matrix. If 6 x 6 square matrices are selected the 26 letters of the alphabet and numbers 0-9 are used with A followed by 1, B by 2, C by 3 and so on up to J followed by 0. A keyed alphabet is created from a key word, with repeated letters being omitted, followed by the unused letters of the alphabet in alphabetic order. The keyed alphabet is written into the matrix in a selected route, e.g. horizontal, diagonal or clockwise. For example the key word FIRSTKEY is appended with unused alphabet letters and produces the following keyed alphabet:

FIRSTKEYABCDGHLMNOPQUVWXZ

Encryption is performed by separating the plaintext into pairs of letters or digraphs. If the plaintext contains an odd number of letters a null letter is added at the end of the text to complete the last letter pair. The first letter of each pair is located in the top left straight alphabet matrix and the second letter is located in the bottom right straight matrix. The cipher pair is the pair of letters in the opposite corners of a square formed by the plaintext letters in the other two 5 x 5 matrices.

a b c d e | F I R S T

f g h i k | K E Y A B

l m n o p | C D G H L

q r s t u | M N O P Q

v w x y z | U V W X Z

S D F M U | a b c d e

E K G P V | f g h i k

C Y H Q W | l m n o p

O A I R X | q r s t u

N B L T Z | v w x y z

Example

Keyword 1: FIRSTKEY (Rows from top left)

Keyword 2: SECONDKEY (Columns from top left)

Plaintext: Who says nothing is impossible. I've been doing nothing for years.


Plaintext: wh os ay sn ot hi ng is im po ss ib le iv eb ee nd oi ng no th in gf or ye ar sx

Ciphertext: WK GR SN OH HR AG DG YR EQ HW OI EM LS KT IU TU HF HP DG HH OP YQ KK DR ZM IO OL

Solving

Solving methods: Hill Climbing and Dictionary keyword search.

Both 5x5 and 6x6 Four Square solvers have been implemented and, when used with the dictionary keyword search a tip is required for the solving routine. After selecting the square size in the Setup drop down menu click on the Solve cipher icon to open the dialog box shown below. This prompts for the tip and tip location to be set. On selecting OK the program will search for a solution using dictionary words as the keywords for the squares.

Tip – Enter the tip in the Tip field. Spaces and punctuation will be ignored.

Click on the Locate tip button to populate the Tip location list with possible locations for the tip.

Tip location – Select the location of the tip from the list then press OK. When a tip location is selected the ciphertext and plaintext positions are shown below the Tip location.

If the Four Square cipher is rerun the previous setting for the tip will be displayed.

Show table and possible keys – Selecting this option will open a new window, when the solving routine is finished, to display the partially completed Four Square table based on the entered tip and location selection and a list of possible keywords and key squares found. If a solution isn’t found the table can be useful for seeing the possible keys and solving the cipher by hand.

If at least one of the keywords is known this can be entered into the Enter Key field on the main window, see 5.2 Keyword Entry, separating them by commas and leaving unknown keywords blank. E.g. “LAUREL,HARDY” or “LAUREL,”. The order of keywords is top right square key followed by bottom left square key.