Polybius Square a cipher where each alphanumeric (a-z, 0-9) character is represented by it’s coordinates in a grid.
❌ Perfect Decoding
✅ Uppercase letters (A-Z)
✅ Lowercase letters (a-z)
✅ Numbers (0-9)
❌ Symbols (!@#$)
❌ Emojis (😍🤬👩🏾💻)
Numbers and Emojis
Symbols and emoji are removed by this cipher.
Spaces are Removed
All spaces are removed by this cipher during encoding.
What is “Perfect Decoding”?
Perfect Decoding is when the decoded text exactly matches the text that was encoded.
This cipher forcibly lowercases all characters, removes spaces, omits symbols and emoji. As a result the output from decoding does not exactly match the original input string.
View Polybius Square on Github
x = Math.floor(letterPosition / 6) + 1
y = (letterPosition mod 6) + 1
characterIndex = (x * 6) + y
Hello World!
ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz
0123456789
!@#$
✨🦄✨
22 15 26 26 33 45 33 36 26 14 11 12 13 14 15 16 21 22 23 24 25 26 31 32 33 34 35 36 41 42 43 44 45 46 51 52 11 12 13 14 15 16 21 22 23 24 25 26 31 32 33 34 35 36 41 42 43 44 45 46 51 52 53 54 55 56 61 62 63 64 65 66
helloworldabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789
letterPosition is the index of the letterx and y are the coordinates of the letter in a 6x6 alphanumeric gridcharacterIndex is the index of the character in a flat alphanumeric arrayThe alphanumeric array consists of the letters a-z and 0-9.
Alphanumeric Array:
abcdefghijklmnopqrstuvwxyz0123456789
Alphanumeric Grid:
a b c d e f
g h i j k l
m n o p q r
s t u v w x
y z 0 1 2 3
4 5 6 7 8 9
The 6 represents the number of rows and columns in the alphanumeric grid.
letterPositionIndex of the letter in the alphanumeric alphabet (0-indexed). For example, A=0, C=2, Z=25, and 9=35.
x and yGiven the grid above, where:
a = 1,1m = 3,1w = 4,59 = 6,6x and y values for a given character in the grid.characterIndexGiven a set of character coordinates (1,1 through 6,6), calculate the 0-index of the letter at that coordinate. This characterIndex is then used to lookup the letter in the alphanumeric array.
modThe formula for encoding uses mod 6. Javascript doesn’t have proper support for mod so this formula is used:
export function mod (a, b) {
return ((a % b) + b) % b
}