Tap Code Explained: How the Knock Code Sent Words Through Prison Walls
How tap code (the knock code) maps letters to a 5x5 grid where C and K share a cell, how POWs talked by knocking, plus encoding, decoding, and CTF puzzles.
Tap Code Explained: How the Knock Code Sent Words Through Prison Walls
A man sits alone in a cell. Speaking is forbidden, the walls are concrete, and the only sound he can make without a guard noticing is a knuckle against stone. Tap, tap. Pause. Tap, tap, tap. To anyone listening it sounds like restless habit. To the prisoner in the next cell it spells the letter H. That is the tap code, also called the knock code, and it turned a wall into a telephone line.
This post walks through how the cipher works, why two letters of the alphabet have to share a single cell, where the code came from, and how you can encode and decode it yourself for a puzzle, a CTF, or a history lesson.
The 5x5 grid, and why C and K share a cell
The whole system rests on a square. Write the alphabet into a 5x5 grid, left to right and top to bottom, and every letter lands at an address: a row number and a column number. That is the trick. Instead of inventing a unique signal for each of 26 letters, you only ever need to count to five twice.
A 5x5 grid has exactly 25 cells, and the alphabet has 26 letters. One letter has to go. The traditional choice is to drop K and fold it into C, so they share the same cell. It works because context almost always fills the gap. Tap out bac k and a reader sees back without a second thought. The cost is one tiny piece of lossiness: type K into a tap code tool and it comes back as C, because once K and C share an address there is no way to tell them apart on the return trip. The grid looks like this:
1 2 3 4 5
1 A B C D E
2 F G H I J
3 L M N O P
4 Q R S T U
5 V W X Y Z
Notice C sits at row 1, column 3, and there is no separate K. Each letter is two groups of taps: you tap the row number, leave a short pause, then tap the column number. A longer pause marks the end of a word. That single rule — row taps, pause, column taps — is everything you need to send any message a knuckle can carry.
Tapping out a word: a worked example
Let me spell HI, the two-letter word a new prisoner learned first because it was the friendliest thing you could send through a wall.
Find H in the grid. It sits in row 2, column 3. So H is two taps, pause, three taps — written out as .. .... Now find I: row 2, column 4. That is two taps, pause, four taps — .. ..... Put them together with a longer gap between letters and HI becomes:
.. ... / .. ....
Read it back the other way and you reverse the lookup. The first burst is the row, the second burst is the column, and you find the cell where they cross. Two-then-three points at H. Two-then-four points at I. A receiver who knows nothing but the grid and the rule can rebuild the word a tap at a time. Count A as a sanity check: row 1, column 1, so it is one tap, pause, one tap — . ., not a single lonely tap. People expect A to be one knock because it is the first letter, but the code always sends both numbers, even when both are 1.
Where the knock code comes from
The tap code most people know was carried by American prisoners of war in Vietnam, above all in the Hỏa Lò prison the captives nicknamed the Hanoi Hilton. Talking was banned, and isolation was the point of the place, so the prisoners needed a way to pass names, news, and encouragement through the walls without a sound a guard would recognise as speech.
Captain Carlyle Harris taught the grid to fellow captives in 1965, adapting an old idea so it could be memorised one cell at a time and taught to a newcomer through a shared wall. The underlying scheme is far older: it descends from the Polybius square of ancient Greece, a 5x5 coordinate grid the historian Polybius described for signalling letters with torches. Tapping was painfully slow — a sentence could take minutes — but it went straight through concrete, and that was the only thing that mattered. Prisoners used it to keep a chain of command alive, to spread the name of a man newly captured, and simply to remind each other that someone next door was still there.
Tap code, the Polybius square, and other ciphers
Because the tap code grows straight out of the Polybius square, the two are nearly the same cipher with one difference: which pair of letters shares a cell. The Polybius square usually merges I and J; the tap code merges C and K. Both turn every letter into a row-column pair. The Polybius square writes that pair as digits, like 23, while the tap code sends the same pair as physical taps. Switch the merged pair and the systems line up exactly, which is why a good tap code tool will happily decode numeric pairs like (2,3) that a puzzle prints out as coordinates instead of knocks. If you work with grids a lot, the Polybius square cipher tool is the natural companion for spotting which merge a puzzle actually used.
This is also why tap code shows up so often in capture-the-flag challenges and escape rooms. A string of dots plus a hint about prison walls is a near-certain giveaway. The tap code translator lets you paste that string in, switch to decode, and read the answer instead of counting taps on paper — and it shows the 5x5 grid right on the page so you can verify a single letter by hand when an organiser uses an unusual symbol.
Using it yourself
I learned the cipher the slow way first, knuckles on a desk, and the thing that surprised me was how quickly the grid stops being a chart you look up and starts being a map you feel. After a dozen words my hand knew that the middle of the alphabet lived around row 3, and I could tap a name without glancing down. That muscle memory is exactly what made the code teachable through a wall, one cell at a time, to a man you had never seen.
A few practical notes. The most common mistake is forgetting that A needs two bursts — drop the second and every letter after it shifts and the message comes out as nonsense. The second is expecting K to survive a round trip; it will not, and MILK coming back as MILC is the cipher working as designed, not a bug. The third is confusing tap code with the Polybius square because both use a 5x5 grid; set the merge you actually mean before you decode.
Whether you are building a scavenger hunt clue, teaching a history class how captives talked through concrete, or staring down a CTF puzzle at two in the morning, the grid is the whole secret. Row taps, pause, column taps. Once you can feel it, a wall is just another way to talk.
Made by Toolora · Updated 2026-06-13