Advertisement
ModerkaScripts

pixcrypt [Encryption & Decryption Library]

May 12th, 2024
464
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.58 KB | None | 0 0
  1. --[[
  2.     pixcrypt
  3.     Key-based Encryption & Decryption Library
  4.     ttwizz.su/pix
  5.  
  6.     Author: ttwiz_z (ttwizz)
  7.     License: MIT
  8.     GitHub: https://github.com/ttwizz/pixcrypt
  9. ]]
  10.  
  11.  
  12. local pixcrypt = {Secret = 2773480762}
  13.  
  14.  
  15. function pixcrypt:Encrypt(Key, String)
  16.     assert(type(Key) == "string", "Argument 1 (Key) must be a string")
  17.     assert(type(String) == "string", "Argument 2 (String) must be a string")
  18.  
  19.     local Summand = #Key + math.pi * 4.3579
  20.     local Result = ""
  21.     local Index = 1
  22.  
  23.     for Character in string.gmatch(Key, ".") do
  24.         Summand = Summand + string.byte(Character) / 1.8602
  25.     end
  26.     for Character in string.gmatch(String, ".") do
  27.         Result = Result .. string.byte(Character) / 2.1748 + Summand * (pixcrypt.Secret / Index) .. "xip"
  28.         Index = Index + 1
  29.     end
  30.  
  31.     return string.gsub(string.reverse(string.sub(Result, 1, -4)), "%.", "$")
  32. end
  33.  
  34.  
  35. function pixcrypt:Decrypt(Key, String)
  36.     assert(type(Key) == "string", "Argument 1 (Key) must be a string")
  37.     assert(type(String) == "string", "Argument 2 (String) must be a string")
  38.  
  39.     local Summand = #Key + math.pi * 4.3579
  40.     local Result = ""
  41.     local Index = 1
  42.  
  43.     for Character in string.gmatch(Key, ".") do
  44.         Summand = Summand + string.byte(Character) / 1.8602
  45.     end
  46.     for Character in string.gmatch(string.gsub(string.reverse(String), "%$", "."), "([^xip]+)") do
  47.         Result = Result .. string.char(math.floor((Character - Summand * (pixcrypt.Secret / Index)) * 2.1748 + 0.5))
  48.         Index = Index + 1
  49.     end
  50.  
  51.     return Result
  52. end
  53.  
  54.  
  55. return pixcrypt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement