Free Tool

Two-Square Cipher Tool

Two keyword squares, horizontal or vertical

Ciphertext

How the Two-Square cipher works

Two-Square is a Playfair cipher with two key squares. Each square is built from its own keyword: the keyword's letters first, each used once, then the rest of the alphabet. The first letter of each pair is always looked up in the first square, and the second letter in the second.

  1. Drop spaces and punctuation and split the message into pairs. Add an X if one letter is left over. Doubled letters need no special treatment.
  2. Find the first letter in the first square and the second letter in the second square. They mark two corners of a rectangle that spans both squares.
  3. The other two corners are the ciphertext:
    • Horizontal (squares side by side): the first cipher letter is in the right square, on the first letter's row. The second is in the left square, on the second letter's row. If both letters are on the same row, the pair just swaps round.
    • Vertical (one above the other): the first cipher letter is in the top square, on the first letter's row and the second letter's column. The second is in the bottom square. If both letters share a column, the pair stays the same.

The vertical form is its own inverse: encrypting the ciphertext again gives the plaintext back.

Example

Vertical layout, keywords EXAMPLE and KEYWORD, Q left out of the alphabet: HELP ME OBI WAN KENOBI becomes HE DL XW SD JY AN HO TK DG. Notice HE and AN come through unchanged, because their letters share a column.

How to break it

  • Look for plaintext showing through. In the vertical form roughly one pair in five is unchanged, so parts of words appear in the ciphertext. In the horizontal form those pairs appear reversed.
  • Pair frequencies. As with Playfair, frequent English pairs give frequent cipher pairs.
  • A known word fixes letter positions in both squares at once. From there the rest of each square can be filled in like a crossword.

History

Two-Square grew out of Playfair in the late 1800s. A German version called Doppelkasten, which ran the text through the squares twice and added a transposition, was used as a field cipher in the Second World War.

Related tools

Questions

What is the difference between horizontal and vertical Two-Square?

Only where the squares sit and what happens when a pair lines up. Side by side (horizontal, the American Cryptogram Association standard), a pair on the same row comes out reversed. One above the other (vertical), a pair in the same column comes out unchanged.

Why are some pairs not encrypted at all?

In the vertical layout, a pair whose letters share a column is left as it is. That happens to about one pair in five, and it is the cipher's biggest weakness: real words show through the ciphertext.

Is Two-Square the same as double Playfair?

Yes, it is often called double Playfair. It uses the Playfair rectangle rule, but each letter of a pair is looked up in its own square.