Advertisement
pepeknamornik

P7_de_crypt

Apr 1st, 2023 (edited)
1,431
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.05 KB | None | 0 0
  1. verze = "23.0401.R1"
  2. local desifra = {}
  3. local i = 1
  4.  
  5. local function decrypt(text, key)
  6.   local result = ""
  7.   for i = 1, #text do
  8.     local byte = text:byte(i)
  9.     local key_byte = key:byte((i - 1) % #key + 1)
  10.     result = result .. string.char(bit.bxor(byte, key_byte))
  11.   end
  12.   return result
  13. end
  14.  
  15. function readEncryptedFile(file, key, radek)
  16.   if not fs.exists(file) then
  17.     error("File not found!")
  18.   end
  19.  
  20.   if fs.isDir(file) then
  21.     error("Cannot read directories!")
  22.   end
  23.  
  24.   local encryptedData = false
  25.   if file:sub(-4) == ".pcr" then
  26.     local inputFile = fs.open(file, "rb")
  27.     encryptedData = inputFile.readAll()
  28.     inputFile.close()
  29.     encryptedData = decrypt(encryptedData, key)
  30.   end
  31.  
  32.   if not encryptedData then
  33.     error("File is not encrypted!")
  34.   end
  35.  
  36.   for line in encryptedData:gmatch("[^\r\n]+") do
  37.     desifra[i] = line
  38.     i = i + 1
  39.   end
  40.  
  41.   if (radek) then
  42.   return desifra[radek]
  43.   else
  44.   return encryptedData
  45.   end
  46.  
  47.  
  48. end
  49.  
  50. --print(readEncryptedFile("/C/system/Users/Administrator/.data.pcr", "0", 2))
  51.  
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement