XOREncryption
XOREncryption copied to clipboard
Lua version
Here's a Lua version
function M.obfuscate(input, key)
key = key or M.obfuscation_key
local output = ""
local key_iterator = 1
local input_length = #input
local key_length = #key
for i=1, input_length do
local character = string.byte(input:sub(i,i))
if key_iterator >= key_length then key_iterator = 1 end -- cycle
local key_byte = string.byte(key:sub(key_iterator,key_iterator))
output = output .. string.char(bit.bxor( character , key_byte))
key_iterator = key_iterator + 1
end
return output
end