Advertisement
Akuukis

Encrypt Agent code LARP NewAge 2014

Sep 15th, 2014
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.03 KB | None | 0 0
  1. local keyUp = {
  2.   {"A","B","C","D","E"},
  3.   {"F","G","H","I","K"},
  4.   {"L","M","N","O","P"},
  5.   {"Q","R","S","T","U"},
  6.   {"V","W","X","Y","Z"},
  7. }
  8. local keyLow = {
  9.   {"a","b","c","d","e"},
  10.   {"f","g","h","i","k"},
  11.   {"l","m","n","o","p"},
  12.   {"q","r","s","t","u"},
  13.   {"v","w","x","y","z"},
  14. }
  15. local input = assert(io.open("normal.txt", "r"), "Failed to open input 'normal.txt' file")
  16. local symbol, ch, text = true, nil, ""
  17. while symbol do
  18.   symbol = input:read(1)
  19.   if symbol == string.char(32) then
  20.     text = text .. " "
  21.   elseif symbol == string.char(10) or symbol == string.char(12) then
  22.     text = text .. string.char(10)
  23.   elseif symbol then
  24.     local code = nil
  25.     for i=1,5 do
  26.       for j=1,5 do
  27.         if symbol == keyUp[i][j] or symbol == keyLow[i][j] then code = i .. j end
  28.       end
  29.     end
  30.     if not code then code = "?" end
  31.     text = text .. code
  32.   end
  33. end
  34. print(text)
  35. input:close()
  36. local output = assert(io.open("encrypted.txt", "w"), "Failed to open output file")
  37. output:write(text)
  38. output:close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement