Advertisement
Diazo

lpjhuijjk

Jan 15th, 2020
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. local keyToInt = function(s)local z=0; for i = 1, #s do z=z+string.byte(i)end return z end
  2.  
  3. local encrypt = function(str, encryptionKey)
  4. local encrypted = ''
  5. for i = 1, #str do
  6. encrypted = encrypted .. '#' .. string.byte(str:sub(i, i)) + keyToInt(encryptionKey)
  7. end
  8. return encrypted
  9. end
  10.  
  11. local decrypt = function(str, encryptionKey)
  12. local decrypted = ''
  13. for x in str:gmatch('#(%d+)') do
  14. decrypted = decrypted .. string.char(x - keyToInt(encryptionKey))
  15. end
  16. return decrypted
  17. end
  18.  
  19.  
  20. local myEncryptedString = encrypt('print("okaycool")', 'flibble')
  21.  
  22.  
  23. print(myEncryptedString)
  24.  
  25.  
  26.  
  27. local myDecryptedString = decrypt(myEncryptedString, 'flibble')
  28.  
  29.  
  30. print(myDecryptedString)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement