Guest User

Untitled

a guest
Nov 22nd, 2014
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.28 KB | None | 0 0
  1. function encryptFile(filePath, encryptedFilePath, key)
  2.     local decryptedFile = fileOpen(filePath, true)
  3.     if decryptedFile then
  4.         local fileContent = fileRead(decryptedFile, fileGetSize(decryptedFile))
  5.  
  6.         fileClose(decryptedFile)
  7.  
  8.         fileContent = teaEncode(fileContent, key)
  9.         if fileContent then
  10.             local encryptedFile = fileCreate(encryptedFilePath)
  11.             if encryptedFile then
  12.                 fileWrite(encryptedFile, fileContent)
  13.                 fileFlush(encryptedFile)
  14.                 fileClose(encryptedFile)
  15.  
  16.                 return true
  17.             end
  18.         end
  19.     end
  20.     return false
  21. end
  22.  
  23. function decryptFile(filePath, decryptedFilePath, key)
  24.     local encryptedFile = fileOpen(filePath, true)
  25.     if encryptedFile then
  26.         local fileContent = fileRead(encryptedFile, fileGetSize(encryptedFile))
  27.  
  28.         fileClose(encryptedFile)
  29.  
  30.         local fileContent = teaDecode(fileContent, key)
  31.         if fileContent then
  32.             local decryptedFile = fileCreate(decryptedFilePath)
  33.             if decryptedFile then
  34.                 fileWrite(decryptedFile, fileContent)
  35.                 fileFlush(decryptedFile)
  36.                 fileClose(decryptedFile)
  37.  
  38.                 return true
  39.             end
  40.         end
  41.     end
  42.     return false
  43. end
  44.  
  45. addEventHandler("onClientResourceStart", resourceRoot,
  46.     function ()
  47.         local key = "K3TOEQaK7W+KZ1m4"
  48.        
  49.         encryptFile("car.txd", "e_car.txd", key)
  50.         decryptFile("e_car.txd", "d_car.txd", key)
  51.     end
  52. )
Advertisement
Add Comment
Please, Sign In to add comment