djb2 Hash Function

后端 未结 4 1727
暖寄归人
暖寄归人 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:30

    You shouldn't do that. Since there is no modulo, integer overflow is the expected behavior for the function (and it was designed with it in mind). Why do you want to change it?

提交回复
热议问题