# Polybius cipher

Polybius cipher is a basic form of encryption invented by the Ancient Greek Historian whose name it bears. It is based on fractionating plaintext characters so they can be represented by a smaller set of symbols. In plain English: all the letters of the alphabet are written in a 5×5 square like the one below:

``` 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```

(Because the Greek alphabet had 25 letter wheres today’s English alphabet has 26 letters we are forced to combine 2 letters into the same symbol, usually I and J; we use common sense to determine which is which)
Each letter is transformed into its coordinates (thus every characters is reduced to a pair of digits none grater than 5).
For example:
ZEUS becomes 55 15 45 43
And we can make it look even better if we substitute the digits 1 to 5 with the letters A to E.
ZEUS becomes EEAEDEDC

```1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 \$excepted_letter='J'; for (\$i=1; \$i<=5; \$i++) { for (\$j=1; \$j<=5; \$j++) { if (chr(\$j+5*(\$i-1)+64)<\$excepted_letter) \$coordinates[chr(\$j+5*(\$i-1)+64)]=\$i.\$j; else \$coordinates[chr(\$j+5*(\$i-1)+65)]=\$i.\$j; } } \$coordinates[\$excepted_letter]=\$coordinates['I'];   \$plain_text=str_split(strtoupper("Zeus")); \$n=count(\$plain_text); \$encrypted_text=''; for (\$i=0; \$i<\$n;\$i++) if (\$plain_text[\$i]!=' ') \$encrypted_text.=\$coordinates[\$plain_text[\$i]]; else \$encrypted_text.=' '; \$search = array('1', '2', '3', '4', '5'); \$replace = array('A', 'B', 'C', 'D', 'E'); \$encrypted_text=str_replace(\$search, \$replace, \$encrypted_text); echo \$encrypted_text;```

Decryption is extremely simple and it only means replacing the keys with the values in the ‘coordinates’ array.
Cracking the Polybius cypher is also very easy, still the method worth mentioning as in combination with other methods or by using a mixed alphabet results in a decent encryption technique for it’s time.

The following riddle will point you to an interesting finding: