After a recent question about cryptography, I got playing with an ancient Greek method of encoding called a Polybus Square with the ultimate intention of making it the core of an encryption scheme.
The script below explains how it works. My problem is that I have incorrectly derived the last two statements in my script which find the row and column for the entry and find myself stabbing in the dark for the mistakes. Try “A” for example, or “J”.
(* POLIBUS SQUARE
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
*)
set tText to "Polybius square, also known as the Polybius ,
checkerboard invented by the Ancient Greek historian
and scholar Polybius, is a scheme for making the alphabet
representable as pairs of numbers which code the
row and column of the letter in the square. Since 26
letters don't fall into place in a 5 x 5 diagram, I and J
are lumped together. The numbers can be added by
using a 6 x 6 if I/J are still lumped together."
--tLetters to {"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"}
set Punc to {13, 32, 44, 46} -- return, space, comma, period
set sq to 5
set tChoice to text returned of (display dialog "Enter the Letter" default answer "")
set Ltr to id of tChoice
if Ltr is in Punc then
set LID to Ltr
else
if Ltr > 96 and Ltr < 123 then set Ltr to Ltr - 32
if Ltr = 75 then set Ltr to 74
set LID to Ltr - 65
end if
set tCol to (LID - 1) mod sq + 1
set tRow to (LID + sq - 1) div sq