affine_cipher(s,a,b):=block([tmp], if not(equal(gcd(a,26),1)) then return("Bad parameters: a is not coprime with 26") else (tmp:mod(a*(map(cint,charlist(s))-97)+b,26), simplode(map(ascii,tmp+65))) )$ affine_decipher(s,a,b):=block([tmp], tmp:mod(inv_mod(a,26)*(map(cint,charlist(s))-65-b),26), simplode(map(ascii,tmp+97)) )$ text_to_numbers(s):=map(cint,charlist(s))-96$ base27(list):=block( sum(reverse(list)[j]*27^(j-1),j,1,length(list)))$ dec2base(n,b):=block([remainders,tmp], remainders:[n], do (tmp:rest(remainders,1), remainders:flatten(push(divide(remainders[1],b),tmp)), if is(first(remainders)