I am using the djb2 algorithm to generate the hash key for a string which is as follows
hash(unsigned char *str) { unsigned long hash = 5381; int c;
return (hash & 0xFFFFFFFF); // or whatever mask you want, doesn't matter as long as you keep it consistent.