Ciphers
Playfair
Letter pairs through a keyed 5×5 table. J folds into I, doubled pairs are split with X, odd length is padded with X.
Cipher / Digraph
Playfair
Letter pairs through a keyed 5×5 table.
- Keyspace
- 25! ≈ 1.5×10²⁵
- Decode
- same options back
- Works on
- A-Z in pairs, J as I, the rest dropped
- Family
- 3 in digraph
required 1 / 1
Options
Access
- Create
create("playfair") - CLI
ciphers encode playfair 'HIDE THE GOLD' --key 'PLAYFAIR EXAMPLE' - Tryplayground with the sample above
- Kinfour-square, two-square
The key fills a 5×5 table, duplicates dropped, rest of the alphabet after it, J folded into I to fit 25 cells. The text is stripped to letters and cut into pairs. Same row - move right. Same column - move down. Otherwise each letter takes the other's column. Two identical letters in a pair get split with an X, and an odd final letter is paired with X. Output is uppercase without spaces, because the input has been reshaped anyway.
const playfair = create("playfair");
playfair.encode("HIDE THE GOLD IN THE TREE STUMP", { key: "PLAYFAIR EXAMPLE" }).text;
// "BMODZBXDNABEKUDMUIXMMOUVIF"
playfair.decode("BMODZBXDNABEKUDMUIXMMOUVIF", { key: "PLAYFAIR EXAMPLE" }).text;
// "HIDETHEGOLDINTHETREXESTUMP"
The round trip keeps the X that split TREE. That's the cipher, not a bug, and every Playfair implementation that claims otherwise is guessing. Key is required and must contain letters. The Wikipedia vector above is the one the test suite checks.