Polybius

The Polybius Square and Its Descendants: From Ancient Greece to WWI Ciphers

Explore how the Polybius square cipher evolved into the Tap Code, Nihilist cipher, Bifid cipher, and ADFGVX cipher. A comprehensive history from 150 BCE to World War I.

Published March 18, 2026
15 minute read
Cryptography Guide

The Polybius Square and Its Descendants: From Ancient Greece to WWI Ciphers

The Polybius square is one of the most influential inventions in the history of cryptography. Conceived around 150 BCE by the Greek historian Polybius, this deceptively simple 5x5 grid transformed every letter of the alphabet into a two-digit coordinate pair. That single idea -- converting characters into numeric coordinates -- proved so powerful that it spawned an entire lineage of ciphers stretching across two millennia. From the tapping walls of prison cells to the muddy trenches of World War I, the descendants of the Polybius square have shaped military history, espionage tradecraft, and the evolution of modern cryptanalysis.

This article traces that lineage from the original Polybius cipher through its most important descendants: the Tap Code, the Nihilist cipher, the Bifid cipher, and the ADFGX/ADFGVX ciphers. Along the way, we will examine how each system built upon the Polybius square's coordinate concept to solve new communication challenges.

The Original Polybius Square (150 BCE)

Polybius the Historian

Polybius was born around 200 BCE in Megalopolis, a city in the Arcadian League of ancient Greece. After the Roman conquest of Greece, he was taken to Rome as a political hostage, where he became a close associate of the powerful Scipio family. His monumental work, The Histories, documented the rise of Rome and covered topics ranging from military strategy to governance. In Book X of The Histories, Polybius described a signaling system that bears his name to this day.

The Torch Signal System

The Polybius square was not originally designed for written encryption -- it was designed for optical telegraphy. The system worked as follows:

  1. Grid construction. The 24 letters of the Greek alphabet were arranged in a 5x5 grid (the 25th cell remained empty or held a special character). Each letter received a unique pair of coordinates: one for the row, one for the column.

  2. Torch transmission. The sender held up two groups of torches simultaneously. The left group indicated the row number (1 to 5 torches), and the right group indicated the column number (1 to 5 torches). A distant observer could count the torches and determine the letter.

  3. Relay stations. Chains of hilltop relay stations retransmitted the signals across vast distances. A message could traverse hundreds of kilometers in a matter of hours -- far faster than any physical messenger.

Mathematical Elegance

The genius of the Polybius square lies in a simple mathematical insight: a 5x5 grid provides exactly 25 unique coordinate pairs, enough to represent any alphabet of 25 or fewer characters. By squeezing every letter into a uniform two-digit format, Polybius reduced the complexity of transmitting arbitrary text to transmitting sequences of small numbers -- a concept that foreshadowed digital encoding by more than two thousand years.

Try the Polybius cipher encoder and decoder to see this system in action.

The Tap Code: Polybius in Prison Walls

How the Tap Code Works

The tap code is perhaps the most humanly compelling adaptation of the Polybius square. Instead of torches or written numbers, the coordinates are transmitted as sequences of audible taps on a wall, pipe, or any hard surface. The sender taps the row number, pauses briefly, then taps the column number. The listener decodes each pair back to a letter.

The tap code typically uses a 5x5 grid where the letter K is omitted (replaced by C in context), rather than the I/J merge of the standard Polybius square:

    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

To send the letter H (row 2, column 3), you would tap twice, pause, then tap three times. To send the letter S (row 4, column 3), you would tap four times, pause, then tap three times.

Vietnam POWs and the Hanoi Hilton

The tap code achieved worldwide recognition through its use by American prisoners of war during the Vietnam War. Hundreds of US servicemen, mostly Navy and Air Force pilots shot down over North Vietnam, were held in the Hoa Lo Prison in Hanoi -- sarcastically nicknamed the "Hanoi Hilton." The prisoners were kept in strict isolation, forbidden from speaking to one another, and subjected to interrogation and torture.

In 1965, Air Force Captain Carlyle "Smitty" Harris introduced the tap code to fellow prisoners after recalling it from a military survival training class. The system spread rapidly through the prison population. Prisoners tapped on walls, swept brooms in rhythmic patterns, coughed in sequences, and even flashed hand signals corresponding to the grid coordinates.

The tap code became a lifeline for the POWs. Through it, they:

  • Shared intelligence about interrogation techniques
  • Coordinated resistance strategies
  • Passed along personal messages and news
  • Maintained group morale during years of captivity
  • Organized a chain of command among prisoners

Commander Jeremiah Denton, who famously blinked the word "TORTURE" in Morse code during a televised propaganda interview, was one of many POWs who relied on the tap code daily. The system's simplicity made it nearly impossible for guards to prevent -- even tapping a sandal against a bed frame could carry a message.

Russian Political Prisoners

Decades before Vietnam, Russian political prisoners in Tsarist and early Soviet prisons used an identical system. The Decembrists, Narodniks, and later Bolshevik revolutionaries tapped coded messages through the thick stone walls of Siberian prisons and the Peter and Paul Fortress in St. Petersburg. Arthur Koestler's novel Darkness at Noon (1940) depicts this communication method in vivid detail.

The tap code's resilience lies in its extreme simplicity: no equipment is needed, the grid can be memorized in minutes, and the tapping can be disguised as ordinary noise. It remains in use in prisons around the world to this day.

The Nihilist Cipher: Adding Arithmetic to Polybius

Origins Among Russian Revolutionaries

The Nihilist cipher emerged in the 1880s among Russian revolutionary groups -- the Narodnaya Volya (People's Will) and related organizations fighting against the Tsarist autocracy. These groups needed a cipher that was stronger than simple substitution but simple enough to use without paper or devices, since discovery of any cryptographic equipment would lead to arrest and execution.

The Nihilist cipher was their solution: layer a keyword-based key on top of the Polybius square through addition, creating a cipher that is only slightly more complex to use but significantly harder to break at first glance.

How the Nihilist Cipher Works

  1. Create a Polybius square. Arrange the 25 letters (I/J merged) in a 5x5 grid, optionally scrambled using a keyword.

  2. Convert plaintext to coordinates. Using the grid, replace each plaintext letter with its two-digit Polybius coordinate. For example, using the standard grid: H = 23, E = 15, L = 31, P = 35.

  3. Convert the key to coordinates. Take a keyword (e.g., "SECRET") and similarly convert each letter to its Polybius coordinate. Repeat the keyword to match the length of the plaintext.

  4. Add the coordinates. For each position, add the plaintext coordinate and the key coordinate. If the plaintext coordinate is 23 and the key coordinate is 43, the ciphertext number is 23 + 43 = 66.

The result is a sequence of two- or three-digit numbers (ranging from 22 to 110) that look quite different from raw Polybius coordinates.

Worked Example

Plaintext:  H   E   L   P
Polybius:   23  15  31  35

Key:        S   E   C   R
Polybius:   43  15  13  42

Ciphertext: 23+43=66  15+15=30  31+13=44  35+42=77
Result:     66 30 44 77

Security Analysis

The Nihilist cipher provides more obscurity than a raw Polybius cipher, but it has a critical weakness: the addition operation preserves patterns. If the same plaintext letter appears at positions where the same key letter is also used, the resulting ciphertext values will be identical. This means the cipher is vulnerable to:

  • Modular analysis: Ciphertext values where the tens digit and units digit are both odd or both even reveal information about the underlying coordinates.
  • Known-plaintext attacks: A single known word can expose portions of the key.
  • Statistical attacks: The sum distribution is not uniform, and experienced cryptanalysts can detect the key length and reconstruct both plaintext and key.

Despite these weaknesses, the Nihilist cipher served the Russian revolutionaries adequately in an era before systematic cryptanalysis was widespread. The Okhrana (Tsarist secret police) did eventually learn to break it, but often not quickly enough to prevent the revolutionaries' actions.

The Bifid Cipher: Polybius Meets Transposition

Felix Delastelle's Innovation

In 1901, the French cryptographer Felix Delastelle published the Bifid cipher, a system that combined the Polybius square with a transposition step to create something fundamentally stronger than either technique alone. Delastelle recognized that the Polybius square's greatest value was not as a cipher in itself, but as a mechanism for fractionation -- splitting each letter into two independent components (the row and column) that could be manipulated separately.

How the Bifid Cipher Works

  1. Create a Polybius square (optionally keyed with a keyword).

  2. Extract coordinates. For each plaintext letter, write down its row number and column number separately, creating two rows of digits.

  3. Concatenate and regroup. Write all the row numbers first, followed by all the column numbers, then divide this combined sequence into pairs.

  4. Convert back to letters. Each new pair of digits is looked up in the Polybius square to produce the ciphertext letter.

Worked Example

Using the standard Polybius grid:

Plaintext:  H   E   L   L   O
Rows:       2   1   3   3   3
Columns:    3   5   1   1   4

Concatenated: 2 1 3 3 3 3 5 1 1 4
Regrouped:    (2,1) (3,3) (3,5) (1,1) (4,_)
              = F     N     P     A     ...

(The actual output depends on whether the regrouping aligns with the period length chosen.)

Why Bifid Is Stronger Than Polybius

The key innovation is that each ciphertext letter depends on two different plaintext letters -- one contributing its row and another contributing its column. This diffusion effect means that:

  • Changing a single plaintext letter affects multiple ciphertext letters.
  • Frequency analysis on individual letters becomes much harder.
  • The relationship between plaintext and ciphertext is non-linear.

Delastelle also invented the Trifid cipher, which extends this fractionation to three dimensions using a 3x3x3 cube, and the Four-Square cipher, which uses multiple Polybius squares simultaneously.

The Bifid cipher remained practically unbreakable by hand methods during Delastelle's lifetime. Even today, breaking a Bifid cipher requires sophisticated hill-climbing or simulated annealing algorithms rather than simple frequency analysis.

ADFGX and ADFGVX: Polybius on the Western Front

The Crucible of World War I

By 1918, four years of trench warfare had turned the Western Front into a communications nightmare. Radio transmissions could be intercepted by the enemy, so every important message had to be encrypted. The German Army needed a cipher that was:

  • Secure against French and British cryptanalysts
  • Simple enough for front-line telegraph operators to use under fire
  • Resistant to Morse code errors during transmission

Colonel Fritz Nebel of the German Army designed the ADFGX cipher to meet all three requirements, and the Polybius square was at its heart.

How ADFGX Works

  1. Polybius substitution. A 5x5 grid is constructed using a secret keyword. The rows and columns are labeled with the letters A, D, F, G, X -- specifically chosen because their Morse code representations (di-dah, dah-di-di, di-di-dah-di, dah-dah-di, dah-di-di-dah) are maximally distinct from each other, minimizing transmission errors.

  2. Columnar transposition. The resulting ADFGX letter pairs are written into a grid under a transposition keyword, then the columns are rearranged alphabetically and read off column by column.

This two-step process (substitution then transposition) produced ciphertext that was extremely difficult to analyze because the transposition thoroughly scrambled the substitution patterns.

The Extension to ADFGVX

In June 1918, the Germans extended the system to a 6x6 grid by adding the letter V (creating six column/row labels: A, D, F, G, V, X). The larger grid accommodated all 26 letters plus the 10 digits, allowing field units to encrypt map coordinates, unit numbers, and other numeric data within the same system.

Georges Painvin's Triumph

The ADFGVX cipher arrived at a critical moment in the war. In the spring of 1918, Germany launched its massive Spring Offensive (Operation Michael), and the Allies desperately needed intelligence about German troop movements and attack plans.

French cryptanalyst Lieutenant Georges Painvin took on the challenge of breaking the ADFGVX cipher. Working with limited intercepts and under enormous time pressure, Painvin exploited subtle statistical patterns in the transposition step. His key insight was that messages encrypted with the same transposition key but starting at different positions in the plaintext would produce column-aligned patterns that leaked information about the key length.

On June 2, 1918, Painvin broke a critical ADFGVX message that revealed the target of the next German attack -- the area between Montdidier and Compiegne. This intelligence allowed the French High Command to reinforce the threatened sector, and the German offensive was stopped at the Second Battle of the Marne. Many historians consider Painvin's feat one of the most consequential cryptanalytic achievements in history.

Painvin's work was so intense that he lost 33 pounds during the weeks of effort. He later said that breaking the ADFGVX cipher was the hardest intellectual task he ever undertook.

The Straddling Checkerboard: Polybius Optimized

The straddling checkerboard is a clever refinement of the Polybius square that addresses one of its biggest practical weaknesses: ciphertext expansion. In a standard Polybius cipher, every letter becomes two digits, doubling the message length. The straddling checkerboard solves this by assigning single-digit codes to the most frequent letters (E, T, A, O, N, etc.) and two-digit codes to less common letters.

The result is a variable-length encoding that produces shorter ciphertext and, crucially, makes frequency analysis much harder because the analyst cannot easily determine where one character's code ends and the next begins.

The VIC Cipher

The most famous application of the straddling checkerboard is the VIC cipher, used by Soviet spy Reino Hayhanen (codenamedVIK, later anglicized to VIC) in the 1950s. The VIC cipher combined a straddling checkerboard with multiple layers of transposition and a complex key derivation process. It was considered one of the strongest hand ciphers ever devised and was never broken by the American intelligence community -- Hayhanen's espionage was uncovered only when he defected in 1957.

The VIC cipher demonstrates how far the humble Polybius square could be pushed when combined with additional cryptographic techniques.

Modern Legacy: Why the Polybius Square Still Matters

More than two thousand years after its invention, the Polybius square continues to appear in surprising places:

Cryptography Education

The Polybius cipher is a staple of introductory cryptography courses at universities worldwide. It elegantly illustrates fundamental concepts -- coordinate systems, bijective mappings, fractionation, and the relationship between substitution and transposition -- in a way that students can grasp immediately. Teaching the Polybius square naturally leads to discussions of the Bifid cipher, ADFGVX, and ultimately modern block ciphers that use similar substitution-permutation network architectures.

CTF Competitions

Capture The Flag (CTF) cybersecurity competitions regularly feature Polybius-encoded challenges. Competitors must recognize the coordinate-pair format, identify whether a standard or keyed grid was used, and apply appropriate solving techniques. The Polybius decoder on this site is a popular tool for CTF players.

Escape Rooms and Puzzle Design

The visual simplicity of the 5x5 grid makes the Polybius cipher ideal for escape room puzzles. Designers can present the grid as a historical artifact, a spy's notebook, or a prison wall carving. Players decode coordinate pairs to reveal clues, passwords, or the combination to a physical lock.

Cultural References

The Polybius square and its derivatives appear in novels, films, and video games. From Tom Clancy thrillers to indie puzzle games, the satisfying click of converting coordinates to letters resonates with audiences who enjoy intellectual challenges.

FAQs

What is the difference between the Polybius square and the Polybius cipher?

The terms are used interchangeably. "Polybius square" refers to the 5x5 grid itself, while "Polybius cipher" refers to the encryption method that uses the grid to convert letters to coordinate pairs. In practice, both terms describe the same system.

Is the Polybius cipher secure?

No. The standard Polybius cipher is a simple monoalphabetic substitution that is trivially broken by frequency analysis. Its value is educational and historical, not practical. For secure communication, use modern encryption standards like AES.

What is the difference between the Polybius cipher and the Bifid cipher?

The Polybius cipher replaces each letter with its grid coordinates directly. The Bifid cipher also uses a Polybius grid to extract coordinates, but then it shuffles (transposes) the row and column digits before converting them back to letters. This extra step creates diffusion, making the Bifid cipher significantly harder to break.

Can I use the Polybius cipher for numbers?

Yes. Use the 6x6 extended grid, which accommodates all 26 letters plus the digits 0-9 (36 characters total). Our online Polybius tool supports both the 5x5 and 6x6 grid configurations.

How is the Polybius cipher used in CTF competitions?

In CTF challenges, you may encounter a string of digit pairs (e.g., "23 15 31 31 34") or letter pairs (e.g., "BC AE CA CA CD") that need to be decoded using a Polybius grid. Sometimes the grid is keyed with a keyword, requiring you to reconstruct it before decoding. Our advanced decoder supports all common formats.

What is the Nihilist cipher?

The Nihilist cipher is a Polybius-derived system where both the plaintext and a keyword are converted to Polybius coordinates, and the corresponding coordinates are added together. It was invented by Russian revolutionaries in the 1880s and is stronger than a raw Polybius cipher but still vulnerable to statistical analysis.

Who broke the ADFGVX cipher?

French cryptanalyst Georges Painvin broke the ADFGVX cipher in June 1918 during World War I. His breakthrough revealed the target of a major German offensive and may have influenced the outcome of the war.

About This Article

This article is part of our comprehensive polybius cipher tutorial series. Learn more about classical cryptography and explore our interactive cipher tools.

Try Polybius Cipher Cipher Tool

Put your knowledge into practice with our interactive polybius cipherencryption and decryption tool.

Try Polybius Cipher Tool