Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local keyToInt = function(s)local z=0; for i = 1, #s do z=z+string.byte(i)end return z end
- local encrypt = function(str, encryptionKey)
- local encrypted = ''
- for i = 1, #str do
- encrypted = encrypted .. '#' .. string.byte(str:sub(i, i)) + keyToInt(encryptionKey)
- end
- return encrypted
- end
- local decrypt = function(str, encryptionKey)
- local decrypted = ''
- for x in str:gmatch('#(%d+)') do
- decrypted = decrypted .. string.char(x - keyToInt(encryptionKey))
- end
- return decrypted
- end
- local myEncryptedString = encrypt('print("okaycool")', 'flibble')
- print(myEncryptedString)
- local myDecryptedString = decrypt(myEncryptedString, 'flibble')
- print(myDecryptedString)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement