function rot13 (s) local byte_a, byte_A = strbyte('a'), strbyte('A') s = gsub(s, "(%a)", function (c) -- change each letter ... c = strbyte(c) local offset = (c >= 97) and %byte_a or %byte_A c = mod(c+13-offset, 26) return strchar(c + offset) end) return s end while 1 do local line = read() if line == nil then break end write(rot13(line), '\n') end