Write a hash algorithm in c language

I don't know C language very well, but I can try to give an implementation of hash algorithm: unsigned int hash(char *str) { unsigned int hash = 5381; int c;

while (c = *str++)
    hash = ((hash << 5) + hash) + c; /* hash * 33 + c */

return hash;

}

Guess you like

Origin blog.csdn.net/weixin_42577735/article/details/129515599