-- rot13.lua - rot13 implementation in lua :) -- (c) 2003 Alexandre Erwin Ittner - aittner@netuno.com.br -- Distributed under the terms of GNU GPL - WITHOUT ANY WARRANTY! -- Applies the rot13 to the string - returns the rot13'd string -- non-ascii characters will pass untouched -- -- normal: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz -- rot13 : NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm function rot13(s) local str = "" local i = 1 while i <= string.len(s) do if string.byte(string.upper(s), i) >= string.byte("A", 1) and string.byte(string.upper(s), i) <= string.byte("Z", 1) then if string.byte(string.upper(s), i) <= string.byte("M", 1) then str = str .. string.char(string.byte(s, i) + 13) else str = str .. string.char(string.byte(s, i) - 13) end else str = str .. string.sub(s, i, i) end i = i + 1 end return str end local a = "" for l in io.lines() do a = a .. "\n" .. rot13(l) end print(a)