Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected result on string XOR #317

Open
ferib opened this issue Jan 7, 2023 · 0 comments
Open

Unexpected result on string XOR #317

ferib opened this issue Jan 7, 2023 · 0 comments

Comments

@ferib
Copy link

ferib commented Jan 7, 2023

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");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant