XaskeL

caesar, xor cipher mtasa

Jul 27th, 2019
175
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local h1, h2, h3 = debug.gethook()
  2. debug.sethook()
  3.  
  4. local gsub = string.gsub
  5. local char = string.char
  6. local byte = string.byte
  7. local bitXor = bitXor
  8.  
  9. local function encodeCaesarXor(str, key)
  10.     return (gsub(str, '.', function(s)
  11.         return char(((bitXor(s:byte(s), 5) + key) % 256))
  12.     end))
  13. end
  14.  
  15. local function decodeCaesarXor(str, key)
  16.     return (gsub(str, '.', function(s)
  17.         return char(((bitXor(byte(s)-key, 5)) % 256))
  18.     end))
  19. end
  20.  
  21. local function caesar(str, key)
  22.     return (gsub(str, '.', function(s)
  23.         return char((byte(s) + key) % 256)
  24.     end))
  25. end
  26.  
  27. local file = fileOpen('1.dff')
  28.     local buffer = fileRead(file, file.size)
  29. fileClose(file)
  30.  
  31. local t=getTickCount()
  32. buffer = caesar(buffer, 1)
  33. print('ms: '..(getTickCount()-t))
  34.  
  35. local file = fileCreate('3.dff')
  36.     local buffer = fileWrite(file, buffer)
  37. fileClose(file)
  38.  
  39. debug.sethook (_, h1, h2, h3)
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×