Four-Square Cipher
Delastelle's digram cipher: four 5×5 squares, two of them keyed
Digram frequency analysis · simulated annealing
Why This Matters
Félix Delastelle developed Bifid and Trifid fractionation and the Four-square digram substitution. The Four-square is his digraphic cousin to Playfair: encrypt letters two at a time, but use two keyed alphabets instead of one. It avoids Playfair's "same row / same column / same letter" edge cases and the needed insertion of X between doubled letters.
Published in his 1902 book Traité Élémentaire de Cryptographie, the Four-square joined the Bifid and Trifid in Delastelle's portfolio of methods built on the Polybius square. The modern procedure is documented by cipher organisations and teaching implementations; this exhibit does not establish a complete military-use history.
Arrange four 5×5 squares (J merged into I) in a 2×2 grid. The top-left and bottom-right are plain alphabets; the top-right and bottom-left are keyed.
┌─────────────┬─────────────┐ │ PLAIN A→Z │ KEY 1 │ ├─────────────┼─────────────┤ │ KEY 2 │ PLAIN A→Z │ └─────────────┴─────────────┘To encrypt a digram: locate the first letter in the top-left and the second in the bottom-right. Read the cipher digram from the top-right (row of letter 1, column of letter 2) and the bottom-left (row of letter 2, column of letter 1).
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 four-square cipher would. Odd-length messages are padded with a trailing X.
A fixed four-square key substitutes digrams. Non-overlapping plaintext-pair counts are therefore relabelled, while individual letter counts need not become uniform. Language scores can guide key searches, but required text length depends on the message and attack.
Hill climbing and simulated annealing test candidate square pairs using language scores. They can become trapped in poor candidates; runtime and success depend on the search budget, text length and scoring model. This page establishes no universal seconds-long recovery guarantee.
| Concept from Four-Square Cipher | Modern Evolution |
|---|---|
| Digram-level encryption | AES transforms 128-bit blocks through multiple rounds; its security is not a direct scaling of this digram table |
| Multiple keyed tables | AES uses a fixed nonlinear byte substitution as one operation within a larger keyed construction |
| Avoiding edge cases (same-row/col) | Block-cipher designs specify complete round rules; avoiding special cases alone does not establish security |
| Exhibit | 43 of 174 |
| Era | Early 20th Century · 1902 publication |
| Trust | Broken |
| Inventor | Félix Delastelle (France) |
| Year | ~1902 |
| Key Type | Two keywords (two keyed squares) |
| Broken By | Digram frequency analysis · simulated annealing |
| Modern Lesson | Fixed mappings preserve digram statistics |