Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = { ... }
- function sep(list, by)
- if string.sub(list, 1, 1) == by then
- list = string.sub(list, 2)
- end
- local newlist = {}
- while true do
- local on = nil
- local done = false
- for i = 1, #list do
- if done == false then
- if string.sub(list, i, i) == by then
- on = i
- done = true
- end
- end
- end
- if on then
- table.insert(newlist, string.sub(list, 1, on - 1))
- list = string.sub(list, on + 1)
- else
- break
- end
- end
- table.insert(newlist, list)
- return newlist
- end
- function encrypt(path)
- if fs.exists(path) and not fs.isDir(path) then
- local fil = fs.open(path, "r")
- local nr = fil.readAll()
- fil.close()
- local newr = ""
- for i = 1, #nr do
- newr = newr.."\\"..string.byte(string.sub(nr, i, i))
- end
- fs.delete(path)
- local fil2 = fs.open(path, "w")
- fil2.write("loadstring('"..newr.."')()")
- fil2.close()
- print("Encrypted "..sep(path, "/")[#sep(path, "/")])
- else
- print("File does not exist")
- end
- end
- function decrypt(path)
- if fs.exists(path) and not fs.isDir(path) then
- local fil = fs.open(path, "r")
- local nr = fil.readAll()
- fil.close()
- local newf = ""
- local newr = string.sub(nr, 13)
- newr = string.sub(newr, 1, #newr - 4)
- local fst = sep(newr, "\\")
- for i,v in pairs(fst) do
- newf = newf..string.char(tonumber(v))
- end
- fs.delete(path)
- local fil2 = fs.open(path, "w")
- fil2.write(newf)
- fil2.close()
- print("Decrypted "..sep(path, "/")[#sep(path, "/")])
- end
- end
- if #tArgs < 2 then
- print("Usage: encrypt <e/d> <path>")
- return
- end
- if string.lower(tArgs[1]) == "e" then
- encrypt(tArgs[2])
- elseif string.lower(tArgs[1]) == "d" then
- decrypt(tArgs[2])
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement