Recently, I want to use the Hash function to generate a unique value based on a string, but I cannot find a useful Hash function. The value generated by Hash functions such as MD5 and SHA built in PHP is too long, I can't use it. I want to intercept it. In this way, I am worried that a hash collision will occur. I 'd like to evaluate what hash is used by high people... recently, I want to use the Hash function to generate a unique value based on a string, but I cannot find a useful Hash function. The value generated by Hash functions such as MD5 and SHA built in PHP is too long, I can't use it. I want to intercept it. I am worried that there will be a hash collision. I 'd like to evaluate what hash functions are used by high people.
Reply content:
Recently, I want to use the Hash function to generate a unique value based on a string, but I cannot find a useful Hash function. The value generated by Hash functions such as MD5 and SHA built in PHP is too long, I can't use it. I want to intercept it. I am worried that there will be a hash collision. I 'd like to evaluate what hash functions are used by high people.
Although it depends on the data to use a hash algorithm, it is difficult to connect to MD5. In fact, I really want to hear why"The value generated by the hash function is too long for me to use". If there is no assessment, simply say that based on your feelings, it would be too much.
What you may need is not a low-collision hash algorithm, but the output of the hash algorithm is compressed.String Compression Algorithm. Since the hash algorithm outputs only 16 character sets, and 94 spaces are removed from the ASCII display characters, this idea should satisfy you.
The output is shortened (that is, the size of the hash value is reduced)NecessityIncrease the probability of hash collision, and do not have any unrealistic fantasies. That is to say, no matter what your algorithm is, as long as the range is reduced, the probability of hash collision willEquivalentIncrease. So if you really need a short output hash function, you don't have to bother looking for it. This method is enough.
The title is not good either. What is the occurrence of hash collision?Inevitable, "SOLVE" the hash Collision itself does not exist.
Although hash collision is a small probability event, it cannot be feared or avoided, especially as "nonexistent ". There must be clear methods to deal with it based on application requirements. My suggestion is either to lengthen the value space of the hash algorithm or to add other comparative features as an additional supplement to the hash algorithm.
The longer the length, the smaller the chance of collision. Reducing the length will inevitably increase the chance of collision. Because you are hiding the original space into the space of the hash generation string, the length of the string determines the size of the space.