Two-Square Cipher
Encode and decode the Two-Square cipher, also called double Playfair — a digraph cipher that enciphers letters in pairs across two keyword-mixed 5×5 squares. It is simpler than the Four-Square yet stronger than Playfair, with a vertical or horizontal layout and a reciprocal design where decoding is the very same operation as encoding. Set both keywords, follow the live grid and the pair-by-pair breakdown, and copy, download, or share the result. Everything runs in your browser.
Keyword 1 (top / left)
Keyword 2 (bottom / right)
25-letter alphabet: Q is removed from the squares and the text, so J keeps its own cell. The two squares are stacked, and same-column pairs pass through unchanged.
Enter text above to see the result here.
Two-square grid
Each plaintext pair is found across the two keyword squares, and the opposite corners of the rectangle it forms are the cipher pair. Keyword cells are highlighted.
Square 1 (top / left)
Square 2 (bottom / right)
How to use Two-Square Cipher
- 1
Choose encode or decode, an alphabet, and a layout
Because the Two-Square is reciprocal, Encode and Decode run the same steps; the choice only sets the output spacing. Pick the I/J-merged alphabet or drop-Q, and the vertical or horizontal layout.
- 2
Enter the two keywords
Type a keyword for the first square and another for the second square. Both sides must share both keywords. Leave one or both blank to use a plain square in its place.
- 3
Type or paste your text
Enter your message and it is converted as you type. The steps panel shows each plaintext pair over the cipher pair it becomes, with transparencies drawn muted.
- 4
Read the two-square grid
Open the grid to see the two keyword squares, stacked or side by side to match the layout, with the keyword cells highlighted so you can trace any pair by eye.
- 5
Copy, download, or share
Copy the result, download it as a text file, or share a link that reopens the tool with your exact text, keywords, alphabet, and layout ready to go.
Understanding the Two-Square Cipher
What is the Two-Square cipher?
The Two-Square cipher, often called double Playfair, is a hand cipher that enciphers letters two at a time using two keyword-mixed 5×5 squares. It sits squarely between Playfair and the Four-Square: Playfair uses one square, the Four-Square uses four, and the Two-Square uses two. It is usually credited to the French cryptographer Félix Delastelle, the same mind behind the Bifid and Four-Square ciphers, and it offers more key material than Playfair while staying easy to work by hand.
Because it works on pairs of letters — digraphs — the Two-Square is a polygraphic substitution cipher. Enciphering pairs flattens the single-letter frequencies that make simple substitution ciphers fall in minutes, and two independent keywords roughly double the key material compared with Playfair. Its one notable quirk is that some pairs are emitted unchanged, a weakness explored below, but as a learnable, elegant cipher it is a favourite in puzzles and capture-the-flag challenges.
How the Two-Square cipher works
Build two 5×5 squares, each holding a keyword-mixed alphabet — the keyword's distinct letters first, in order and without repeats, then the rest of the alphabet. Because 26 letters must fit in 25 cells, one letter is folded, classically by merging I and J into a single cell.
To encipher a pair, locate the first letter in the first square and the second letter in the second square. The two letters mark out a rectangle spanning the squares; the cipher pair is read from the two opposite corners, each staying within its own square. Decoding needs no separate procedure: the Two-Square is reciprocal, so running the exact same steps on the cipher pair returns the original plaintext pair. That self-inverse property is one of the cipher's most charming features.
Vertical and horizontal layouts
The two squares can be arranged in two ways. In the vertical layout they are stacked, one above the other: the first letter of each pair is found in the top square, the second in the bottom square, and the cipher letters share the same rows but swap columns. In the horizontal layout the squares sit side by side: the first letter is found in the left square and the second in the right, and the cipher letters share columns but swap rows.
The two layouts produce different ciphertext from the same keywords, so they are effectively distinct settings the sender and receiver must agree on. With keywords EXAMPLE and KEYWORD and the drop-Q alphabet, the message HELP ME OBI WAN KENOBI encrypts to HE DL XW SD JY AN HO TK DG in the vertical layout, but to XG NB ME BP AI RY PG ES HB in the horizontal layout. Pick the layout above and the live grid re-stacks to match.
The two keywords and the alphabet
The Two-Square cipher has two independent secrets: a keyword for each square. Each square is built exactly like a keyed Playfair or Polybius square — unique keyword letters first, then the remaining alphabet — and the live grid below highlights the keyword cells so you can watch the mixing. Both sender and receiver must share both keywords, the same alphabet variant, and the same layout.
You can leave a keyword blank to use a plain alphabetical square in its place. Leaving both blank makes the two squares identical, which turns the cipher into a fixed letter-pair transposition — a handy way to see the geometry before any keyword mixing is layered in. For real use, two strong, different keywords give the most security.
A worked Two-Square example
Take HELP ME OBI WAN KENOBI with keyword 1 EXAMPLE and keyword 2 KEYWORD, using the drop-Q alphabet and the vertical layout. The text splits into the pairs HE, LP, ME, OB, IW, AN, KE, NO, BI. For HE, H is in the top square and E in the bottom square; because they share a column, the pair passes straight through unchanged as HE — a transparency.
For LP, L is in the top square and P in the bottom square in different columns, so the rectangle's other corners give D in the top square and L in the bottom square: LP becomes DL. Carrying on, the whole message enciphers to HE DL XW SD JY AN HO TK DG. Notice that HE and AN reappear unchanged. Because the cipher is reciprocal, decoding with the same keywords, alphabet, and layout runs the very same steps and recovers HELPMEOBIWANKENOBI.
Transparencies: the Two-Square's weakness
The Two-Square has a famous flaw: whenever the two letters of a pair already share the swapped coordinate — the same column in the vertical layout, or the same row in the horizontal layout — the cipher pair is identical to the plaintext pair. These give-away pairs are called transparencies, and on average about one digraph in five comes out unchanged.
Transparencies leak plaintext straight into the ciphertext and gave cryptanalysts a foothold, which is why the Two-Square was eventually considered weaker than alternatives without this property. The breakdown panel draws transparencies in a muted style so you can see exactly how often they occur for your text and keywords — a vivid illustration of why even a clever hand cipher can betray its message.
Two-Square versus Playfair and Four-Square, and security
The Two-Square is a middle ground in Delastelle's family of square ciphers. It improves on Playfair by using two keywords instead of one and by never needing to split doubled letters — because the two halves of a pair come from different squares, a pair like LL or EE enciphers cleanly. The Four-Square goes further with four squares and no transparencies, at the cost of more setup; the Two-Square keeps things lighter but pays for it with the transparency weakness.
By modern standards the Two-Square is still a classical cipher and not secure against a computer. Like all digraph substitution ciphers it preserves letter-pair frequencies, and its transparencies make it especially vulnerable, so with enough text it yields to digraph-frequency analysis and known-plaintext attacks. Its value today is educational. For protecting real information, always use a modern, peer-reviewed algorithm such as AES, and keep the Two-Square for history, puzzles, and capture-the-flag challenges.
Frequently asked questions
What is the Two-Square cipher?
How does the Two-Square cipher work?
What is the difference between the vertical and horizontal layouts?
Why is the Two-Square called double Playfair?
Can you show a worked Two-Square example?
What are transparencies in the Two-Square cipher?
How do you decode a Two-Square cipher?
How is the Two-Square different from the Four-Square cipher?
What is the difference between I/J merged and drop-Q?
What happens to spaces, numbers, and punctuation?
Do I have to use a keyword in both squares?
Is my text uploaded to a server?
Related tools
Keep going with these handy tools