Convert hash algorithm from c to java

Can anybody help me with conversion of following hash alghorithm to java.

int gg_login_hash(char *password, int seed)

{

unsigned int x, y, z;

y = seed;

for (x = 0; *password; password++) {

x = (x & 0xffffff00) | *password;

y ^= x;

y += x;

x <<= 8;

y ^= x;

x <<= 8;

y -= x;

x <<= 8;

y ^= x;

z = y & 0x1f;

y = (y << z) | (y >> (32 - z));

}

return y;

}

thanks in advance

pt

[541 byte] By [pt4siek] at [2007-9-30 20:49:52]
# 1
Remove the word "unsigned" and replace the pointer iteration with proper array access. Job done, AFAICS. Course, you might want to narrow the scopes of the variables too.
YATArchivist at 2007-7-7 2:22:54 > top of Java-index,Other Topics,Algorithms...
# 2
how can i narrow scopes?i think that's good idea to keep int as longs to avoid buffer overflow.
pt4siek at 2007-7-7 2:22:54 > top of Java-index,Other Topics,Algorithms...
# 3

A lot of your variable arent needed outside the loop, so you should, instead of declaring them likeint z;

for (whatever) {

you should do the oppositefor (whatever) {

int z;

Also, you are going to have to come up with a new way to iterate through the string.

Michael_Lorton at 2007-7-7 2:22:54 > top of Java-index,Other Topics,Algorithms...