String to Integer Hashing Function with Precision

后端 未结 4 1744
滥情空心
滥情空心 2021-01-19 10:35

I want to hash a char array in to an int or a long. The resulting value has to adhere to a given precision value. The function I\'ve been using is given below:



        
4条回答
  •  说谎
    说谎 (楼主)
    2021-01-19 11:11

    Every hash will have collisions. Period. That's called a Birthday Problem.

    You may want to check cryptographic has functions like MD5 (relatively fast and you don't care that it's insecure) but it also will have collisions.

提交回复
热议问题