Two Square

History

The Two Square cipher is a variation of the Playfair cipher and was first described in Military Cryptanalytics Part 1, Volume 1, 1956 by William Friedman and Lambros D Callimahos.

Description

As its name implies it consists of two polybius squares and text is enciphered in digraphs or letter pairs. To encipher text using the Two-Square cipher two 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. 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 keyword, with repeated letters being omitted, followed by the unused letters of the alphabet in alphabetical order. The keyed alphabet is written into the matrix in a selected route, e.g. horizontal, diagonal or clockwise. For example the keyword FUNNY is reduced to FUNY when repeated letters are removed. Appending unused alphabet letters produces the following keyed alphabet:

FUNYABCDEGHIKLMOPQRSTVWXZ

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 first matrix and the second letter is located in the second matrix. The cipher pair is the pair of letters in the opposite corners of a square formed by the plaintext letters. If the two plaintext letters are in the same row the letters are reversed to produce the ciphertext.


1 2 3 4 5 | 1 2 3 4 5

1 F U N Y A | 1 Q A G M V

2 B C D E G | 2 U B H N W

3 H I K L M | 3 O C I P X

4 O P Q R S | 4 T D K R Y

5 T V W X Z | 5 E F L S Z

Example

Keyword 1: FUNNY (Rows from top left)

Keyword 2: QUOTE (Columns from top left)

Plaintext: The early bird gets the worm, but the second mouse gets the cheese.

Plaintext: th ee ar ly bi rd ge ts th ew or mb ut th es ec on dm ou se ge ts th ec he es ex

Ciphertext: LB UX MS XR HH DR UZ ST LB WE RO CG QP LB NX BL RB NN TB TZ UZ ST LB BL OT NX WL

Solving

Solving methods: Hill Climbing and Dictionary keyword search.

Both 5x5 and 6x6 Two Square solvers have been implemented and, when used with the dictionary keyword search, require a tip for the solving routine. On selecting the Solve cipher icon the dialog box below will appear to enable the tip and tip location to be set. On selecting OK the program will search for a solution.

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

Click on the Locate tip button will 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 confirming the location selected.

If the Two Square cipher is rerun the previous entry 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 Two 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 help to solve 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 separating them by commas and leaving unknown keywords blank. E.g. “SECURITY,EQUATOR” or “SECURITY,”. The order of keywords is left square key then right square key.