Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local keyUp = {
- {"A","B","C","D","E"},
- {"F","G","H","I","K"},
- {"L","M","N","O","P"},
- {"Q","R","S","T","U"},
- {"V","W","X","Y","Z"},
- }
- local keyLow = {
- {"a","b","c","d","e"},
- {"f","g","h","i","k"},
- {"l","m","n","o","p"},
- {"q","r","s","t","u"},
- {"v","w","x","y","z"},
- }
- local input = assert(io.open("normal.txt", "r"), "Failed to open input 'normal.txt' file")
- local symbol, ch, text = true, nil, ""
- while symbol do
- symbol = input:read(1)
- if symbol == string.char(32) then
- text = text .. " "
- elseif symbol == string.char(10) or symbol == string.char(12) then
- text = text .. string.char(10)
- elseif symbol then
- local code = nil
- for i=1,5 do
- for j=1,5 do
- if symbol == keyUp[i][j] or symbol == keyLow[i][j] then code = i .. j end
- end
- end
- if not code then code = "?" end
- text = text .. code
- end
- end
- print(text)
- input:close()
- local output = assert(io.open("encrypted.txt", "w"), "Failed to open output file")
- output:write(text)
- output:close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement