Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Crypt(path,pass)
- if fs.exists(path) and not fs.isDir(path) and path ~= "/startup" and path ~= "/crypt" then
- write("[FILE]: "..path.."... ")
- local Tab={}
- local F = fs.open(path,"rb")
- while true do
- local N = F.read()
- if N == nil then break end
- table.insert(Tab,N)
- end
- F.close()
- F = fs.open(path,"wb")
- for k, v in pairs(Tab) do
- F.write(bit.bxor(v,string.byte(pass,k%string.len(pass)+1)))
- end
- F.close()
- print("[DONE]")
- end
- end
- function CryptIn(path,pass)
- if fs.exists(path) and fs.isDir(path) and path ~= "/rom" and path ~= "/disk" then
- for k, v in pairs(fs.list(path)) do
- if fs.isDir(path.."/"..v) then
- CryptIn(path.."/"..v,pass)
- else
- Crypt(path.."/"..v,pass)
- end
- end
- end
- end
- local msg
- local pass
- if not fs.exists("_TMSG") then
- print("[Encoding]")
- write("Enter Password: ")
- pass = read("*")
- write("Enter Test Message: ")
- msg = read()
- local F = fs.open("_TMSG","w")
- F.write(msg)
- F.close()
- else
- print("[Decoding]")
- write("Enter Password: ")
- pass = read("*")
- Crypt("_TMSG",pass)
- write("Test Message: ")
- local F = fs.open("_TMSG","r")
- print(F.readAll())
- F.close()
- write("Continue?[Y/N]: ")
- while true do
- local YN = read()
- if YN == "Y" then
- fs.delete("_TMSG")
- break
- elseif YN == "N" then
- Crypt("_TMSG",pass)
- return
- end
- end
- end
- CryptIn("",pass)
Advertisement
Add Comment
Please, Sign In to add comment