Task

Implement functions to encrypt and decrypt a message using the straddling checkerboard method. The checkerboard should take a 28 character alphabet (A-Z plus a full stop and an escape character) and two different numbers representing the blanks in the first row. The output will be a series of decimal digits.

Numbers should be encrypted by inserting the escape character before each digit, then including the digit unencrypted. This should be reversed for decryption.




var [const]
   val2key=Dictionary(
    "A","30",  "B","31",  "C","32",  "D","33",  "E","5",   "F","34",  "G","35",
    "H","0",   "I","36",  "J","37",  "K","38",  "L","2",   "M","4",   ".","78", 
    "N","39",  "/","79",  "O","1",   "0","790", "P","70",  "1","791", "Q","71", 
    "2","792", "R","8",   "3","793", "S","6",   "4","794" ,"T","9",   "5","795",
    "U","72",  "6","796", "V","73",  "7","797", "W","74",  "8","798", "X","75",
    "9","799", "Y","76",  "Z","77"),
   key2val=val2key.pump(Dictionary(),"reverse");
 
fcn encode(txt){ txt.toUpper().pump(String,val2key.find.fp1("")) }
fcn decode(str){ RegExp("79.|3.|7.|.").pump(str,String,key2val.get) }