/* the famous DJB Hash Function for strings */
unsigned int DJBHash(char *str)
{
unsigned int hash = 5381;
while (*str){
hash = ((hash << 5) + hash) + (*str++); /* times 33 */
}
hash &= ~(1 << 31); /* strip the highest bit */
return hash;
}
for more information: String hash functions compare