20 lines
595 B
Plaintext
20 lines
595 B
Plaintext
sequence alpha_b = repeat(0,255)
|
|
alpha_b['A'..'Z'] = 'A'
|
|
alpha_b['a'..'z'] = 'a'
|
|
|
|
function caesar(string s, integer key)
|
|
integer ch, base
|
|
for i=1 to length(s) do
|
|
ch = s[i]
|
|
base = alpha_b[ch]
|
|
if base then
|
|
s[i] = base+remainder(ch-base+key,26)
|
|
end if
|
|
end for
|
|
return s
|
|
end function
|
|
string s = "One fine day in the middle of the night, two dead men got up to fight. \n"&
|
|
"Back to back they faced each other, drew their swords and shot each other. %^&*()[",
|
|
e = caesar(s,5),
|
|
r = caesar(e,26-5) ?e ?r
|