Advertisement
Tatantyler

XOR Encryptor

Nov 25th, 2012
439
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.43 KB | None | 0 0
  1. local args = {...}
  2. if #args < 2 then
  3.     print("USAGE: encryptor [file] [key]")
  4. end
  5. local key = tonumber(args[2])
  6. local bytes = {}
  7.  
  8. local handle = fs.open(args[1], "rb")
  9. while true do
  10.     local byte = handle.read()
  11.     if byte then
  12.         table.insert(bytes, bit.bxor(byte, key))
  13.     else
  14.         break
  15.     end
  16. end
  17. handle.close()
  18.  
  19. local enc_handle = fs.open("data", "wb")
  20. for i,v in ipairs(bytes) do
  21.     enc_handle.write(v)
  22. end
  23. enc_handle.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement