djb2 Hash Function

后端 未结 4 1718
暖寄归人
暖寄归人 2020-12-16 04:49

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;
         


        
4条回答
  •  天涯浪人
    2020-12-16 05:26

    return (hash & 0xFFFFFFFF); // or whatever mask you want, doesn't matter as long as you keep it consistent.

提交回复
热议问题