The intercepted scrolls sat heavy on the low desk, every line choked with scrambled symbols. Al-Kindi rubbed his ink-stained fingers and tried another guess. He swapped one mark for another, then another, but the text just stayed nonsense. His messengers waited nearby, hands resting on sword hilts, while enemy forces moved closer to the city. Random guessing burned through days, and every wrong swap led straight to a dead end. The scholars at the House of Wisdom had tried every trick they knew, yet the enemy’s code held firm.
Frustration finally pushed him away from the cipher and toward a neat stack of routine court letters instead. As he scanned those official decrees, a clear pattern jumped out. Some Arabic shapes repeated constantly, while others barely showed up. He realized the administration relied on substitution ciphers that shuffled letters but kept their natural habits intact. He grabbed smooth pebbles and started dropping them into columns, counting every single letter. The pile for Alif grew the tallest by far.
That simple tally gave him his working chain. He took the scrambled marks as his raw material, lined them up next to his pebble columns, and drew a direct line from the tallest secret pile to the tallest Arabic letter pile. Swapping the most frequent symbol instantly revealed the second most common, then the third. The jumbled lines dissolved into plain words almost instantly. The decoded warning spelled out a precise ambush along the valley road, complete with exact troop positions and timing. He packed the parchment and sent it straight to the commander.
The general unrolled the message inside his tent, his shoulders dropping as he traced the new route on the map. The army marched along the open ridge instead, leaving the hidden trap completely empty. Al-Kindi returned to his desk, leaving the cracked cipher resting beside his ink pot. The ink on his hands finally dried as the camp settled into quiet readiness. He wrote down the method in Risalah fi Istikhraj al-Mu'amma around 850 AD, producing the first known manuscript on cryptanalysis and frequency analysis.