-
Posted by sakizen on Mon, 15 Aug 2011 14:34:46
Hi guys, I'm back :)
I have my addon basically completed, however I have to use an external application, similar to WoWHead's Loot tracker, to send the data to my server.
So I am using VB.NET for this for now.
Basically I am trying to convert `
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`
into... ` 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`
However my VB.NET function doesn't seem to return anything.
My goal is to have both programming languages return the same hash code from the piece of text.
I realize this is a primarily LUA help but I figured some people will also know VB.NET as well. Any suggestions? Thanks in advance.
-
Posted by jnwhiteh on Mon, 15 Aug 2011 14:36:13
Sorry, I can't help with VBA. Perhaps someone else can.