The Polybius Square Cipher: How a 5x5 Grid Turns Letters Into Numbers
A practical guide to the Polybius square cipher: how the 5x5 grid maps each letter to a row and column pair, its link to the tap code, and why it still shows up in CTFs.
The Polybius Square Cipher: How a 5x5 Grid Turns Letters Into Numbers
The Polybius square is one of the oldest ideas in cryptography that you can still use in five minutes. You draw a 5x5 grid, write the alphabet into it, and replace every letter with a pair of numbers: which row it sits in and which column. That is the entire scheme. No keys you have to memorize, no math beyond counting to five, and yet it has survived more than two thousand years of reuse, from ancient Greece to prison cell walls to weekend capture-the-flag puzzles.
This guide walks through how the square works, where it came from, why it shows up so often, and where its security ends. If you want to follow along letter by letter, the Polybius square cipher encoder and decoder draws the live grid as you type, so you can watch each coordinate land.
A grid that turns letters into coordinates
Start with a 5x5 table and lay the alphabet across it, left to right, top to bottom. Five rows of five cells gives you 25 slots, but English has 26 letters, so one cell has to do double duty. By long convention I and J share a slot. The standard square looks like this:
1 2 3 4 5
1 A B C D E
2 F G H I/J K
3 L M N O P
4 Q R S T U
5 V W X Y Z
Here is the one concrete rule that matters: each letter becomes a row, column pair, read row first, column second. A is row 1, column 1, so it encodes to 11. B is row 1, column 2, so it is 12. Reading is strictly row then column, never the other way around. If a decoded message comes out as gibberish, the first thing to check is whether someone read a pair backwards.
Let me work one letter fully. Take H. Scan down the rows: A B C D E in row 1, then F G H in row 2. H is the third cell of row 2, so its row is 2 and its column is 3. H encodes to 23. Run the same logic across a whole word and HELLO becomes 23 15 31 31 34. Decoding reverses it: take 23, go to row 2, column 3, read off H, and continue two digits at a time.
From ancient Greece to the back of every codebreaking book
The square is named after Polybius, a Greek historian writing in the second century BCE. His actual interest was not secrecy. He described how you could signal letters across a distance at night using torches: hold up a number of torches on the left to give the row, then a number on the right to give the column. Two groups of torches per letter, and a whole message could cross a valley with nothing but firelight and a shared grid. Encryption was almost a side effect. The real invention was reducing 25 letters to two small numbers each, which made the alphabet transmittable through any channel that can count.
That reduction is why the square never went away. Once letters are just pairs of digits from 1 to 5, you can carry them through torches, taps, knocks, dots, or a column of numbers on a CTF scoreboard. The medium changes; the grid stays.
The tap code: a Polybius square you can knock
The most famous real-world descendant is the tap code. Take the same 5x5 grid, drop the J slot, and you can send any letter by knocking: tap the row number, pause, tap the column number. WATER becomes 52 11 44 15 43, which on a wall sounds like five taps, pause, two taps, then one tap, pause, one tap, and so on.
This was not a parlor trick. American prisoners of war in Vietnam used the tap code to talk through cell walls, passing names and messages by knuckle when speaking was forbidden. It works because it needs nothing but a shared grid and the ability to count, which is exactly the Polybius square's original promise. If you would rather encode a short message into knocks or beeps the way it sounds rather than the way it taps, the Morse code translator is the closest cousin, trading the 5x5 grid for dots and dashes.
Why CTFs and puzzle makers keep reaching for it
In capture-the-flag competitions, a wall of two-digit numbers between 11 and 55 is a near-certain tell. When a challenge hands you a stream like 33 15 31 51 11 24 31 34 with a hint about a "5x5 grid," it is almost always a Polybius square. The numbers resolve to a word, and the word is often the flag or a clue to the next stage.
I have run into this more times than I can count during practice sets, and the giveaway is always the same: pairs of digits where neither digit goes above 5. Once I spotted that ceiling, decoding was just a lookup. The trick that wastes the most time is forgetting that a keyword can reshuffle the grid. A keyword front-loads its unique letters before the rest of the alphabet, so A is no longer 11, and every coordinate shifts. If the plain grid produces nonsense, try a keyword you noticed in the challenge text before you give up.
Puzzle and escape-room designers like the square for the opposite reason: it looks like a lock combination. A clue printed as coordinate pairs next to a drawn grid reads as numbers, not letters, so players have to recognize the grid before they can solve it. That extra layer of recognition is half the fun, and a keyword keeps anyone who already knows the A=11 layout from shortcutting it.
Two things that trip people up
Two mistakes cause most failed decodes. The first is the I/J merge. Because both letters share cell 24, decoding always returns I, never J, so a decoded INJURE shows up as INIURE. That is the grid working as designed, not a bug; you restore the J by reading for sense.
The second is the coordinate origin. The classic square runs 11 to 55, but some sources start the numbering at 0, so the same letter is 11 in one scheme and 00 in the other. Decode a 11-to-55 stream against a 0-based grid and every row and column shifts by one, turning the whole message to noise. Match the origin to whatever produced the digits, and if you used a keyword to encode, you must use the identical keyword to decode.
It is a code, not a lock
Here is the part worth saying plainly: the Polybius square is not real encryption. With no keyword, the grid is public knowledge that anyone can redraw from memory. Even with a keyword, all you have done is reshuffle 25 letters, which a determined person can recover by hand or a script can brute-force in moments. Use it for puzzles, CTF practice, escape rooms, and teaching the row-column idea before harder grid ciphers like Playfair, Bifid, or ADFGVX. Never use it to protect a password or anything you genuinely need kept private.
If you want a cipher with an actual key that resists casual cracking better, a keyed substitution like the Vigenère cipher is the natural next step up, though it too falls to known attacks and belongs in the same puzzle-and-learning bucket rather than anything load-bearing. The Polybius square's real value is conceptual. It is the gateway grid: the first place students meet the 5x5 layout that a whole family of stronger ciphers reuses, and the cleanest demonstration that a message is just letters, letters are just positions, and positions are just numbers you can carry anywhere.
Made by Toolora · Updated 2026-06-13