Advertisement
guitarplayer616

Encrypt Backup

Jun 22nd, 2015
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.73 KB | None | 0 0
  1. local tArgs = {...}
  2. local h
  3. local file = tArgs[1]
  4. local data
  5.  
  6. if fs.exists(shell.resolve(file)) then
  7.     h = fs.open(file,'rb')
  8. else
  9.     error()
  10. end
  11.  
  12. local l = fs.open("tmp",'w')
  13. local str = ""
  14.  
  15. while true do
  16.   data = h.read()
  17.   if data then
  18.     if tArgs[2] == "c" or nil then
  19.       data = data - 5
  20.     elseif tArgs[2] == "p" then
  21.       data = data + 5
  22.     end
  23.         str = str..string.char(data)
  24.   else
  25.     break
  26.   end
  27. end
  28.  
  29. l.write(str)
  30. l.close()
  31.  
  32. function replace()
  33.   h = fs.open(file,'w')
  34.   l = fs.open("tmp",'rb')
  35.     local str = ""
  36.   while true do
  37.     local dat = l.read()
  38.     if dat then
  39.       str = str..string.char(dat)
  40.     else
  41.      break
  42.     end
  43.   end
  44.   l.close()
  45.   h.write(str)
  46.   h.close()
  47. end
  48.  
  49. replace()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement