$hash function - 23/09/04 03:26 AM
hey, I was wondering if anyone knew the algorithm for the $hash function? I'm sure its simple, but I havn't been able to find anything.
u_long hash(char far *text, int bits) { unsigned int y; char far *p; u_long x; int i; x = 0; y = 0; p = text; while (*p) { y = (int)((x & (u_long)0xff000000L) >> 24); x += (unsigned char)*p; x += y; x = x << 8; p++; } for (i=0;i<(32-bits);i++) { y = (int)(x & 1); x = x >> 1; x += y; } x = (x & ((int)pow(2,bits) - 1)); return x; }