Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local term = require("term")
- local component = require("component")
- local event = require("event")
- local m = component.modem
- local str="0"
- -- determine what channel people want to listen on
- term.write("What channel do you want to chat on? \n")
- local channel=io.read()
- m.open(tonumber(channel))
- -- begin event
- event.listen("modem_message", function(_,_,from,port,_,message)
- -- decipher, and print
- local cipher = "1234567890qwertyuiopasdfghjklzxcvbnm"
- local function decrypt(str)
- str = str:gsub("%d",function(a) return string.char(cipher:find(a,nil,true)+47) end)
- str = str:gsub("%l",function(a) return string.char(cipher:find(a,nil,true)+86) end)
- return str
- end
- if string.sub(tostring(message), 1, 9)=="encrypted" then
- str=tostring(message)
- message=decrypt(str)
- print("Got a message from " .. from .. " on port " .. port .. ": " .. tostring(message))
- else
- print("Got a message from " .. from .. " on port " .. port .. ": " .. tostring(message))
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement