Home › Ciphers › Two-Square Cipher

Two-Square Cipher

The two-square cipher — also called double Playfair — splits each plaintext pair across two keyed 5×5 squares: the first letter is located in one square, the second in the other, and the ciphertext pair is read off the rectangle the two positions define. Because a pair lives in two alphabets at once, the system loses Playfair's most exploitable habits — no doubled-letter filler is needed, and a pair and its reverse no longer mirror each other — while staying a pencil-and-paper method a field clerk can run. This tool implements both historical layouts, vertical and horizontal, states the convention in full, and discloses the one weakness that survives: the collapsed rectangle, worked in full below.

In short

The two-square cipher enciphers letter pairs across two keyed 5×5 squares (J folded into I in both). Each ciphertext letter keeps the row of its own plaintext letter and takes the column of the other letter, read in its own square — or, in the horizontal layout, keeps its column and takes the other's row. The transform is its own inverse: encoding and decoding are the same motion.

Also called double Playfair. Catalogued by Delastelle; a staple of the ACA's digraph listings.

Encode or decode — a traced example is loaded

12 letters
Encoded · Two-square · vertical · SECRET / CIPHER
FOEFELFOBBZK

First square SECRT ABDFG HIKLM NOPQU VWXYZ · second square CIPHE RABDF GKLMN OQSTU VWXYZ

Everything runs in your browser — nothing is uploaded.

How it works

One rectangle across two squares

Both squares are keyed the Playfair way — keyword letters first, repeats dropped, then the unused letters in order, J merged into I — and the message is read in pairs: letters only, J as I, with a single X padding an odd final letter. Double letters within a pair need no filler, because the two letters live in different squares. In the vertical layout the squares are stacked: the pair's first letter is found in the TOP (first) square, the second in the BOTTOM (second) square. Each ciphertext letter keeps the row of its own letter and takes the column of the other: the first ciphertext letter sits in the first square on the first letter's row at the second letter's column, and the second mirrors it in the second square. In the horizontal layout the squares stand side by side — first letter in the LEFT square, second in the RIGHT — and the rule transposes: each ciphertext letter keeps its own letter's column and takes the other letter's row, read in its own square.

The transform is its own inverse in both layouts — the same rectangle read backwards — so Decode applies the same geometry, which the mode toggle above demonstrates. One weakness survives, and this page discloses it rather than hiding it: if both letters of a pair happen to sit in the same column of their respective squares (vertical layout — the same row, horizontally), the rectangle collapses and the pair encrypts to itself, unchanged. The next section works a real case.

Origin & history

Playfair, doubled

The two-square is the natural strengthening of Playfair's 1854 system: where Playfair squeezes a digraph into one square and pays for it with filler letters and reciprocal pairs, the two-square gives each letter of the pair its own keyed alphabet. The construction belongs to the same late-nineteenth-century French school that produced the four-square — Delastelle catalogued the digraph systems together in his 1902 treatise — and it travelled under both its names, "two-square" in the ACA's listings and "double Playfair" in the manuals. It saw the modest field and training use typical of hand digraph systems: stronger than Playfair against casual analysis, still cheap to teach, and obsolete the moment rotor machines arrived.

Reference

The loaded squares

First square (SECRET)SECRT · ABDFG · HIKLM · NOPQU · VWXYZ
Second square (CIPHER)CIPHE · RABDF · GKLMN · OQSTU · VWXYZ
Vertical ruleFirst letter in square 1, second in square 2; each output keeps its own row and takes the other's column
Horizontal ruleFirst letter in the left square, second in the right; each output keeps its own column and takes the other's row

Take the first pair of the loaded example, AT. A sits in the first square at row 2, column 1; T sits in the second square at row 4, column 4. The first ciphertext letter keeps A's row (2) and takes T's column (4) in the first square: row 2 is ABDFG, column 4 is F. The second keeps T's row (4) and takes A's column (1) in the second square: row 4 is OQSTU, column 1 is O. AT becomes FO — and the tool's note under the controls prints both squares for whatever keywords you set, so every pair can be traced the same way.

Worked examples

Both layouts, and the leak

Example 1 — vertical: ATTACK AT DAWN

ATTACK AT DAWN → FOEFELFOBBZK

Run live above. The pairs run AT → FO (traced in the Reference), TA → EF, CK → EL, AT → FO, DA → BB, WN → ZK. Notice DA → BB: doubled letters are legal in two-square ciphertext — the first visible difference from Playfair, where a doubled ciphertext pair can never occur.

Example 2 — the collapsed rectangle, disclosed

MEET ME AT NOON → MERQMEFONOUK

With the very squares above, the pairs ME and NO come out exactly as they went in, because M and E both sit in column 5 of their squares, and N and O both sit in column 1 — "keep your row, take the other's column" changes nothing, and the pair passes through unencrypted. A solver who spots an unchanged, plausible digraph in two-square ciphertext has been handed two letters of plaintext and a fact about both squares. Historical users accepted the leak because the alternative (Playfair) leaked differently; modern readers should simply know it exists. Change either keyword and every column moves — closing the hole for that pair, while possibly opening it for another.

Example 3 — horizontal: the same text, the transposed rule

ATTACK AT DAWN → NDGIKINDDAIZ

Switch the layout control to Horizontal with the same keywords: the squares stand side by side, each letter keeps its own column and takes the other's row, and the same plaintext gives a wholly different ciphertext. The two layouts do not decode each other — when a message refuses to read in one, try the other.

Breaking it

Solving the double Playfair

Two-square falls to the standard digraph attack, one size up from Playfair's: ciphertext digraph frequencies are matched against English digraph frequencies, and the rectangle constraints — each pair ties four cells across two squares — prune candidate squares hard once a few digraphs are placed. The collapsed rectangle is the solver's gift: an unchanged plausible pair (TH, ME, NO…) in ciphertext is two free plaintext letters and two column facts. What the system genuinely buys over Playfair is the loss of the reciprocal-pair tell (AB → XY no longer implies BA → YX) and of the filler-letter noise; what it cannot buy is freedom from digraph statistics, which is why no hand digraph system survived the computer.

  • Security status: puzzle and training grade — stronger than Playfair, broken by digraph analysis.
  • What gives it away: doubled ciphertext pairs (impossible in Playfair), J's absence, and any collapsed pair standing unchanged.
  • The working order: digraph frequencies first, rectangle constraints to place the squares, collapsed pairs as free cribs.
Variants

Two-square or four-square?

RelativeHow it differsSolve it with
PlayfairOne square, both letters inside it — filler letters for doubles, and reciprocal pairsThe Playfair page
Four-squareFour squares: both plaintext letters located in plain squares, ciphertext read from keyed ones — no collapsed-rectangle leakThe Four-square page
TrisquareThree squares, and a third ciphertext letter spent on the crossing — the family's expansion memberThe Trisquare page
BazeriesTwo squares again, but the key is a number that works twice: spelled out in words it keys one square, and read as digits it chops the message into groups and reverses each one before substitutionThe Bazeries page
Seriated PlayfairPlayfair digraphs written into a period grid and read off in columns — Playfair plus transpositionThe Seriated Playfair page

The clean separation from four-square: two-square has two squares, both keyed, and each plaintext letter is located in its "own" square. Four-square's extra machinery buys a larger effective key and removes the collapsed-rectangle leak entirely; two-square stays simpler to teach and to run by hand, and its transform is reciprocal, where four-square's are mirror images. Both are digraph systems on the Polybius foundation.

Uses & culture

Manuals, classrooms, puzzle hunts

Two-square lives where Playfair lives, one shelf up: in the ACA's digraph listings, in cryptogram courses that use it to teach why pair structure matters, and in puzzle hunts that want a hand system a determined solver can actually finish. Its cultural role is mostly comparative — it is the system you meet on the way from Playfair to four-square, and the cleanest demonstration that adding a second keyed alphabet removes some weaknesses (fillers, reciprocals) while leaving the statistical one untouched.

Practice

Trace the rectangles

Practice 1 — encode HELLO WORLD on the loaded squares

HELLO WORLD → ?

Pairs HE LL OW OR LD. The double L is legal — no filler. H is in the first square at row 3, column 1; E in the second at row 1, column 5.

Reveal the answer

MCKMOWNALD — HE → MC, LL → KM, OW → OW (a collapsed pair: O and W both sit in column 2 of their squares, so OW passes through unchanged — the disclosed weakness, caught in the wild), OR → NA, LD → LD collapses too (L and D both sit in column 4). Two collapses in five pairs is unusually unlucky; it is also exactly what a solver prays for.

Practice 2 — decode ZK on the loaded squares

ZK → ?

Decoding is the same motion: Z in the first square, K in the second, keep rows, swap columns.

Reveal the answer

WN — Z sits at row 5, column 5 of the first square; K at row 3, column 2 of the second. First letter: row 5, column 2 of square 1 = W. Second: row 3, column 5 of square 2 = N. The last pair of Example 1, read backwards.

FAQ

Frequently asked questions

Is two-square the same as double Playfair?

It is the same system under its other name — "double Playfair" because it doubles Playfair's one square into two. It is not Playfair applied twice, which would be a different (and much weaker) construction. The giveaway in ciphertext: doubled pairs occur and J never does.

Which layout should I use, vertical or horizontal?

Whichever matches the message you are decoding — the two layouts give different ciphertext from the same text and keys, and neither decodes the other's output. Vertical (stacked squares) is the more common textbook presentation and this page's default; horizontal appears in several manual systems. When in doubt, try both: only one will produce English.

Why did the pair in my message come out unchanged?

The collapsed rectangle: both letters sat in the same column of their respective squares (vertical layout), so the rule returned them as-is. It is a documented property of the system, not a bug in the tool — Example 2 above works a full case. Change either keyword and the columns move.

Does two-square need the X filler between double letters?

No. Playfair needs it because a double pair would sit in one cell of one square; here the two letters live in different squares, so LL encrypts like any other pair. Only an odd-length message is padded, with a single X, which decoding returns for you to trim.

Next steps