So I am working on a small project. A video game uses a scripting engine called LUA so people can create their own UI modifications in game. Which is why I am also using LUA.
I am trying to convert this LUA function into a VB.NET function and...
local function StringHash(text)
local counter = 1
local len = string.len(text)
for i = 1, len, 3 do
counter = math.fmod(counter*8161, 4294967279) + -- 2^32 - 17: Prime!
(string.byte(text,i)*16776193) +
((string.byte(text,i+1) or (len-i+256))*8372226) +
((string.byte(text,i+2) or (len-i+256))*3932164)
end
return math.fmod(counter, 4294967291) -- 2^32 - 5: Prime (and different from the prime in the loop)
end
and this is what I got, however...
Private Function StringHash(ByVal s As String) As Long
Dim counter As Integer = 1
Dim len = s.Length
For i As Integer = 1 To len Step 3
counter = ((counter * 8161) Mod 4294967279) + (Asc(s.Substring(i, 1)) * 16776193) + ((Asc(s.Substring(i + 1, 1)) Or (len - i + 256)) * 8372226) + ((Asc(s.Substring(i + 2, 1)) Or (len - i + 256)) * 3932164)
Next
Return counter Mod 4294967291
End Function
It does not seem to return anything. Any Suggestions?
Thanks in advance