randomdude999

Drive Encrypter

Oct 16th, 2015
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.64 KB | None | 0 0
  1. local args = {...}
  2.  
  3. if #args < 4 then
  4.   print("DriveCrypter - a drive encrypting tool")
  5.   print("Usage: " .. fs.getName(shell.getRunningProgram()) .. " <encrypt | decrypt> <key> <init. vector> <path>")
  6.   print("Uses AES to encrypt the given files.")
  7.   return
  8. end
  9.  
  10. local func = args[1] or ""
  11. local key = args[2] or ""
  12. local iv = args[3] or ""
  13. local path = args[4] or ""
  14.  
  15. if not fs.isDir(path) then
  16.   error("Invalid path",0)
  17. end
  18.  
  19. if not fs.exists("filehidercli") then
  20.   local webHandle = http.get("http://pastebin.com/raw.php?i=wQ1aUnpU")
  21.   if webHandle then
  22.     local apiData = webHandle.readAll()
  23.     webHandle.close()
  24.     local apiHandle = fs.open("filehidercli",'w')
  25.     apiHandle.write(apiData)
  26.     apiHandle.close()
  27.   else
  28.     if not http then
  29.       error("File Hider CLI is not present and the HTTP API is disabled.\nPlease either aquire File Hider CLI manually (from Pastebin wQ1aUnpU, must be saved as filehidercli in /) or enable the HTTP API.")
  30.     else
  31.       error("File Hider CLI is not present and you either you don't have Internet or Pastebin's servers are down.\nFile Hider CLI is a required dependecy and the program can't continue.")
  32.     end
  33.   end
  34. end
  35.  
  36. local function listAll(_path,_files)
  37.   local path = _path or ""
  38.   local files = _files or {}
  39.   if #path > 1 then table.insert(files,path) end
  40.   for _,file in ipairs(fs.list(path)) do
  41.     local path = fs.combine(path,file)
  42.     if fs.isDir(path) then
  43.       listAll(path,files)
  44.     else
  45.       table.insert(files,path)
  46.     end
  47.   end
  48.   return files
  49. end
  50.  
  51. for _,filename in ipairs(listAll(path)) do
  52.   shell.run("filehidercli",filename,func,key,iv,filename)
  53. end
Advertisement
Add Comment
Please, Sign In to add comment