Jash string hash function with avalanche effect

When testing with String.hashCode (), I noticed that it has no avalanche effect. I know there is a Jenkins hash java port, but I was wondering if there is a hash function, maybe in some apache library or something else that has this property.

Edit: I'm looking for a function that demonstrates this property, and returns a 32-bit (or 64-bit) integer (like a Hankins hash for example). I do not use it for cryptography, and I am not going to replace String.hashCode in general. I just thought that hashCode has this property, and it turns out this is not happening, and I am wondering if there is anything in the standard Java libraries or maybe apache lib that suits my needs.

+1
java hashcode hash
source share
1 answer

The avalanche effect described on the wikipedia page with which you are associated is an important property of cryptographic hash functions. String.hashCode() not a cryptographic hash function. Its sole purpose is to generate sufficiently distributed hash codes for different strings so that HashMap, HashSet, and all other hash collections are effective in storing strings.

For cryptographic hash functions, check out JCA , which allows you to generate SHA-1, MD5 and other cryptographic digests that all have the effect you're looking for.

+3
source share

All Articles