function getKey()
while true do
io.write('Insert the numeric key: ')
local chave = tonumber(io.read())
if chave then
return chave
end
end
end
function frase()
io.write('Insert the text: ')
return io.read()
end
while true do
if os.getenv('APPDATA') then os.execute('cls') else os.execute('clear')
end
print('1) encrypt\n2) decrypt\n3) exit')
while true do
io.write('>>')
local resp = tonumber(io.read())
if resp then
if resp == 3 then
os.exit()
elseif resp == 1 then
print(encrypt(frase(),getKey()))
io.read()
break
elseif resp == 2 then
print(decrypt(frase(),getKey()))
io.read()
break
end
end
end
end