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]

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.
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.