moonsharp-devs/moonsharp

Unexpected result on string XOR

ferib opened this issue · 0 comments

ferib commented

Hello, I was playing around with MoonSharp and noticed the result from my snipper below differs from the results in my Lua 5.2 IDE.

Please have a look at the snippet below, the function v7 will take string arg1 and string arg2, turn them into a byte, and XOR them with each other. The result of the XOR is saved in a table that later on will be concatenated. The expected result for this snippet is to return a string with the value test1234567890, however, when executed in MoonSharp I get test123ô567890

local v0 = string.char;
local v1 = string.byte;
local v2 = string.sub;
local v3 = bit32 or bit;
local v4 = v3.bxor;
local v5 = table.concat;
local v6 = table.insert;
local function v7(v8, v9)
	local v10 = {};
	for v11 = 1, #v8 do
		v6(v10, v0(v4(v1(v2(v8, v11, v11 + 1)), v1(v2(v9, 1 + ((v11 - 1) % #v9), 1 + ((v11 - 1) % #v9) + 1))) % 256));
	end
	return v5(v10);
end
return v7("\211\3\183\226\254\19\213\255\146\80\243\174\246\17", "\167\102\196\150\207\33\230\203");