Two-Square Cipher
Delastelle's simpler sibling of Four-square — two keyed 5×5 squares
Digram frequency · same-row leak
Why This Matters
A pared-down version of the Four-square: only two keyed squares, side by side. Slightly easier to use by hand but with a glaring weakness — when a digram's two letters happen to lie in the same row of their respective squares, the ACA output-order convention reverses the pair. For independent uniformly distributed positions, a same-row event has probability 1/5; ordinary text need not follow that distribution.
Published alongside the Four-square in Delastelle's 1902 treatise. The "horizontal" variant places the squares side by side; a "vertical" variant stacks them. Horizontal layouts can have a same-row transparency; vertical layouts have a corresponding same-column case. Exact output-order conventions matter. Used recreationally rather than militarily.
Arrange two keyed 5×5 squares horizontally. For each digram, look up the first letter in the left square and the second in the right square. Read the ciphertext from the opposite corners of the rectangle they form.
If the two letters share a row → reverse their order. Otherwise: cipher[0] = right[ row(L), col(R) ] cipher[1] = left[ row(R), col(L) ]
Rule and source: The current engine follows the horizontal output order in the American Cryptogram Association specification and worked example. Older museum corpus records used a different transformation; prefix a key with legacy: only when replaying those records. That mode is not the ACA rule.
About this demo: To guarantee that Decrypt exactly restores your original message, this demo reversibly escapes the letters X, Q, and Z (as ZA, ZB, ZC) before enciphering, so padding and filler X can never be confused with a real letter. Messages containing X, Q, or Z therefore produce slightly different ciphertext than a strictly classical two-square cipher would. Odd-length messages are padded with a trailing X.
The same-row case occurs with probability 1/5 under a uniform independent-position model, not necessarily for an English message. Such cases can provide hypotheses from common English digrams (TH, HE, IN, ER) appearing in reverse order in the ciphertext. Those hypotheses still need testing against the rest of the message.
A fixed two-square mapping can leak digram statistics. Search methods exploit this structure, but success and required sample length depend on the key conventions, plaintext and available evidence.
| Concept from Two-Square Cipher | Modern Evolution |
|---|---|
| Transparent or reversed pairs as clues | A repeated structural feature may supply clues; isolated fixed points alone do not determine security |
| Two keyed squares | Two keyed squares are not equivalent to HMAC or a modern two-key security proof |
| Exhibit | 44 of 169 |
| Era | Late 19th Century · ~1902 |
| Trust | Broken |
| Inventor | Félix Delastelle (France) |
| Year | ~1902 |
| Key Type | Two keywords (two keyed squares) |
| Broken By | Digram frequency · same-row leak |
| Modern Lesson | Beware of identity transformations as edge cases |