Home › Ciphers › Trisquare Cipher

Trisquare Cipher

The trisquare — the three-square system — closes this site's square family: where Playfair encrypts a digraph inside one square and the four-square inside four, the trisquare stands two keyed alphabets with a third keyed square between them, and turns every plaintext digraph into a ciphertext trigraph. Three letters out for two letters in is expensive traffic, and the system was always more catalogue curiosity than field cipher — but it is the family's logical extreme, and its geometry is genuinely elegant: the middle letter of each trigraph is taken from the key square at the coordinates the two plaintext letters define. This tool implements the standard construction, states its one classical freedom honestly, and is verified against the published worked example in the only direction that can pin it — decode.

In short

The trisquare cipher uses three keyed 5×5 squares over a 25-letter alphabet (A–Y: Z is omitted, J is kept). For each plaintext digraph, the middle letter of the ciphertext trigraph is fixed — the key square's letter at (row of the first letter in square 1, column of the second in square 2) — while the outer letters are classically free within a column and a row; this tool fixes them by a stated rule so its output is reproducible.

The ACA's "Tri-Square" type (100–125 groups). The square family's expansion member: two letters in, three out.

Encode or decode — the published example's squares are loaded

7 letters
Encoded · Trisquare · ONE / TWO / THREE
HKGXNXGAFWAV

Square 1 ONEAB CDFGH IJKLM PQRST UVWXY · square 2 TWOAB CDEFG HIJKL MNPQR SUVXY · key square THREA BCDFG IJKLM NOPQS UVWXY · odd length — Y padded the final digraph

Everything runs in your browser — nothing is uploaded.

How it works

Two letters in, three letters out

Build three keyed 5×5 squares over the 25-letter alphabet A–Y — note the convention, which surprises Playfair users: Z is the omitted letter and J is kept, as in the ACA's sheet and the published examples. Square 1 comes from the first keyword, square 2 from the second, square 3 — the key square — from the third. For a plaintext digraph (a, b): find a in square 1 and note its row and column; find b in square 2 and note its row and column. The trigraph's middle letter is forced: the letter of square 3 standing at (a's row, b's column) — the crossing point of the two letters' coordinates. The first letter must come from a's column of square 1, and the third from b's row of square 2 — the classical construction leaves their exact positions to the encipherer, a freedom the field operator could use as noise.

This tool fixes the free letters deterministically and says so: the first letter is square 1's letter at (b's row, a's column), the third is square 2's letter at (b's row, a's column). Decoding needs only the middle letter and those two fixed companions read back through the same squares, so the round trip is exact under the stated convention — and, crucially, decoding never needed the encoder's freedom resolved: any letter in the right column decodes identically, so ciphertexts from freer implementations still open here as long as their squares match. That asymmetry — strict to write, liberal to read — is why the verification example below is a decode of a published ciphertext. An odd final letter is padded with Y, the alphabet's last letter (the pad the published example uses), and a decode input whose length is not a multiple of three is refused by name.

Origin & history

The family's logical extreme

The trisquare belongs to the square-cipher family that Delastelle's 1902 treatise organised — Polybius's coordinates, Playfair's digraphs, the two-square and four-square systems — and it is the family's endpoint: the construction that spends an extra ciphertext letter to carry the coordinate crossing itself. The American Cryptogram Association catalogues it as Tri-Square, a 100–125-group constructor's type, with the construction stated exactly as this page implements it: any letter in the first letter's column for the first cipher letter, the key square's crossing for the second, any letter in the second letter's row for the third. It was never a field system — telegraphy charged by the letter, and a system that bills three for two needed a better reason than elegance — so its history is the catalogue's history: a specimen of how far coordinate geometry can be pushed, kept in print by the ACA and the reference literature.

Reference

The loaded squares, and one traced digraph

Square 1 (ONE)ONEAB · CDFGH · IJKLM · PQRST · UVWXY
Square 2 (TWO)TWOAB · CDEFG · HIJKL · MNPQR · SUVXY
Key square (THREE)THREA · BCDFG · IJKLM · NOPQS · UVWXY
Alphabet25 letters, A–Y: Z omitted, J kept — the reverse of the Playfair habit

Trace the first digraph of the published example, ME. M stands in square 1 at row 3, column 5; E stands in square 2 at row 2, column 3. The middle letter is the key square at (row 3, column 3) = K — forced, and the same in every correct implementation. The published example's encoder chose T for the first letter (any of B, H, M, T, Y — M's column in square 1) and D for the third (any of C, D, E, F, G — E's row in square 2), giving the trigraph TKD. This tool's stated rule takes the crossing letters instead — H (square 1 at row 2, column 5) and G (square 2 at row 2, column 5) — giving HKG for the same digraph: different outer letters, the same forced middle, and both decode to ME.

Worked examples

The published example, pinned by decode

Example 1 — decode the published ciphertext

TKDGNVSAFRAV → MESSAGEY

The reference worked example (dCode's, on the ACA construction) enciphers MESSAGE with these very squares and prints TKDGNVSAFRAV. Set the tool to Decode and run it: the result is MESSAGEY — the message plus its Y pad. Every middle letter also matches on encode: this tool's encodes of ME, SS, AG, EY give middles K, N, A, A, exactly the published trigraphs' middles. That double pin — decode exact, middles exact — is the strongest verification a system with free letters allows.

Example 2 — this tool's encode of the same text

MESSAGE → HKGXNXGAFWAV

Run live above. Same squares, same middles (K, N, A, A in positions 2, 5, 8, 11), different outer letters — the stated crossing rule instead of the published example's choices. Decode it and MESSAGEY returns. Two correct encoders, two different ciphertexts, one plaintext: the free letters made visible, not hidden.

Breaking it

Attacking three squares

The free letters look like protection and are not: they add noise the analyst can ignore, because only the middle letter of each trigraph carries the crossing, and the outer letters betray their column and row for free. An attack therefore works trigraph by trigraph — the middle letters form a digraph system over the key square driven by (row of a, column of b), and digraph frequency analysis plus the column/row constraints from the outer letters place the three squares together. The 50% expansion gives the analyst more material per message, not less. Trisquare's security was never the point; its geometry was.

  • Security status: a catalogue and study system — the expansion buys elegance, not strength.
  • What gives it away: ciphertext in trigraphs, no Z anywhere, and middle letters that behave like a digraph cipher.
  • The working order: strip the outer letters' column/row facts, then solve the middles as a digraph system.
Variants

The square family, complete

RelativeHow it differsSolve it with
Two-squareTwo squares, digraph in and digraph out — no expansion, no free lettersThe Two-square page
Four-squareFour squares: plaintext read in plain squares, ciphertext from keyed ones — fully determinedThe Four-square page
PlayfairOne square and the rectangle rule inside it — the ancestor of them allThe Playfair page
PhillipsOne square, eight stepped rotations of it — the family's other catalogue extremeThe Phillips page

Read as a set, the family charts one idea's whole career: a 5×5 grid is a coordinate system, and classical cryptography spent a century discovering what coordinates can do — point at letters, pair them, split them, recombine them, and finally spend a third letter to carry the crossing. Trisquare's expansion is why the career ended there.

Uses & culture

A constructor's specimen

Trisquare survives where the ACA keeps it: as a constructor's type in The Cryptogram, set and solved for the geometry's sake, and as a reference example in the cipher literature of a system with genuine slack in it — one of the very few classical systems where two correct encryptions of the same text can differ, which makes it a favourite teaching case for the difference between a cipher and an encoding rule. It also completes this site's square catalogue, which is its own kind of use: a solver who has worked the whole family has learned coordinate thinking itself.

Practice

Check the middles

Practice 1 — encode HELLO on the loaded squares

HELLO → ?

Digraphs HE, LL, OY (Y pads the odd letter). Whatever outer letters you choose, the middles are forced — predict them first: H is at row 2 of square 1 and E at column 3 of square 2, so the first middle is the key square's (2, 3).

Reveal the answer

This tool gives HDGLMKUAS. The middles are D, M, A: key square (2,3) = D for HE; (3,5) = M for LL; (1,5) = A for OY. If your hand-worked trigraphs differ in the outer letters but carry these middles, they are correct — and they decode here.

Practice 2 — why can't an encode pin this cipher?

TKD or HKG — which is the "right" encryption of ME?

Both appeared on this page for the same digraph and squares. Decide what a test of a trisquare tool may legitimately assert.

Reveal the answer

Both are right. The construction fixes only the middle (K) and the column/row of the outers; TKD is the published example's choice, HKG is this tool's stated rule. A legitimate test asserts the decode (unique) and the middles (forced) — never one encoder's free choices. That is the standard this page's build suite applies.

FAQ

Frequently asked questions

Why three letters out for two in?

Because the construction spends them: the middle letter carries the coordinate crossing (the actual encryption), while the outer letters carry the column and row information the decoder needs to reverse it. The expansion is the price of making the system self-contained — no separate key stream travels with the message.

Will ciphertext from another trisquare tool decode here?

Often, yes — decoding depends only on the middle letters and on which column and row the outer letters stand in, not on the exact outer letters chosen. If the other tool used the same three squares and the same A–Y alphabet, its trigraphs open here even if its outer-letter rule differed. Its encodings will differ from this tool's, which is expected and stated on this page.

Why is Z refused instead of merged?

Because the published construction omits Z and keeps J — merging Z into something else would silently change the squares and break compatibility with the published examples this page is pinned to. The tool refuses Z by name rather than guess. If your text needs Z, respell it (the German habit, TZ, works) before enciphering.

Why is the verification a decode, not an encode?

Because of the free letters: two correct encoders can legitimately produce different trigraphs, so an encode-side example cannot pin the construction. The decode direction is fully determined — given the reference's squares and its published ciphertext, exactly one plaintext is correct — which makes it the honest vector. The middle letters, which are determined on encode, are pinned separately.

Next steps