✖

Polybius square: cipher and tap code

The Polybius square writes the letters of the alphabet into a 5 × 5 grid and then replaces each letter with a pair of numbers: the row and the column it lies in. A is in the first row and the first column, so it is 11, H is in the second row and the third column, so 23. The word “ahoj” (Czech for “hello”) is written as 11 23 34 24. It is sometimes called the Polybius cipher or the cipher square. The prisoners’ tap code is built on the same principle. The whole alphabet can thus be sent with just five different signals, for example with fingers, torches or tapping on a wall.

What the cipher square looks like

The letters are written into the square row by row, in alphabetical order. The row numbers are on the left, the column numbers at the top:

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

Why do I and J share one place? A 5 × 5 square has only 5 · 5 = 25 cells, but the international alphabet has 26 letters, so two of them have to share a cell. Most often it is I with J, because the reader can easily tell them apart from the sense: “iak se mas” (Czech for “how are you”, with I in place of J) will hardly confuse anyone.

Watch the order of the numbers. We write the row first, then the column, so B is 12. Some charts reverse this, though, and B is 21 in them. Both work; the sender and receiver just have to agree on it in advance.

Converter from text to the Polybius square and back

Enter some text and the converter makes pairs of numbers from it. It separates letters with a space and words with a slash. It drops accents and writes J as I.

The default text, “Sraz v osm u brány”, is Czech for “meet at eight at the gate”.

It works in the opposite direction too: paste in pairs of numbers and you get text. It is enough to separate the pairs with a space, or to write them straight after each other (1123 is AH); separate words with a slash. A pair that is missing from the chart (for example 61 or 70) is replaced with the character #. The number 24 is read as i, so you have to fill in J from the context yourself.

A cipher square with a keyword

A square with the letters in alphabetical order is really a code, not a cipher. It has no secret key, that is, nothing known only to the sender and the receiver, and anyone can build the chart. It becomes a true cipher when the letters are written into the square in a scrambled order. The simplest way is a keyword: with the key TÁBOR (Czech for “camp”) the square begins with the letters T, A, B, O, R and then continues with the rest of the alphabet without them, that is C, D, E, F, G, H, I/J, K, L, M, N, P… A letter that repeats in the word is written only the first time.

The tap code

The tap code gets by with almost the same square. Here, though, C and K share a cell instead of I and J, so J has its own place and K is tapped as C:

1 2 3 4 5
1 A B C/K 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

A letter is sent by first tapping as many times as the number of the row, then waiting a moment and tapping as many times as the number of the column. Between letters there is a longer pause.

The animation taps SOS. S lies in the fourth row and the third column, so you tap four times, pause, and three times. O is three times and four times.

The tap code square, in which the fourth row and the third column are highlighted for S, then the third row and the fourth column for O and S again; under the square, blue dots are added for the row and red ones for the column The tap code square, in which the fourth row and the third column are highlighted for S, then the third row and the fourth column for O and S again; under the square, blue dots are added for the row and red ones for the column

You do not have to remember the whole square. It is enough to know the letters that the rows begin with, A, F, L, Q, V, and work out the rest from the alphabet. This holds for both squares. The number of taps for the column then says which letter of the row it is: three taps for the row means the row starting with L, and two for the column gives its second letter, that is M.

Why five signals are enough

The number cipher needs its own number for every letter, that is 26 different marks; see the number cipher. The Polybius square instead fixes a letter by two coordinates, like a square on a chessboard. Each coordinate has five possibilities and together they give

5⋅5=25

different pairs. That almost covers the alphabet, which is why five signals are enough. The price we pay is that each letter needs two numbers instead of one.

Morse code gets by with two signals, a dot and a dash, but its codes have different lengths, from one signal to four. Letters therefore have to be separated by a pause. The Polybius square has all its codes the same length, so it is clear that after two numbers the next letter begins.

Where the Polybius square comes from

The square was described by the Greek historian Polybius in the 2nd century BC in the tenth book of his Histories. He attributed the invention to Cleoxenus and Democleitus, and by his own account improved it himself. It was a way of sending messages over a distance with torches: the letters were divided into five tables, the number of torches raised on the left gave the table and the number of torches on the right gave the letter in it.

According to tradition, the tap version was passed on by political prisoners in tsarist Russia, who could talk to each other only through a cell wall. It became most famous in Vietnam, though: American prisoners of war in Hỏa Lò Prison in Hanoi began using it in 1965 and exchanged messages by tapping for years.

How to break the Polybius square

A square with the alphabet in order hides no secret. A row of pairs made only of the digits 1 to 5 gives away at first glance what it is. With a square with scrambled letters, frequency analysis helps: each letter always has the same pair, so the most common pair in a longer message probably belongs to the most common letter of the language.