News for hackers. Stuff that matters.
Re:String.hashCode() is plenty unique by dmurray on Saturday August 11, 2018 @05:43AM (#17739043)
Suppose there are 100 billion computers in the world, including phones, smart watches, toasters, etc. Suppose each of those can perform at the level of a state of the art specialized mining ASIC, 10 million million hashes per second, and they've all been generating 256-bit hashes constantly for 30 years, or a billion seconds.

Suppose further that sha256 is pretty good and the probability of a collision is close to that of random chance.

Then there have been 1e33 sha256 hashes generated ever. Looking at the probability table on Wikipedia for the birthday problem [0] and the row for 256 bits, interpolating it gives a probability of 1e-10 that there has been a collision.

So there would be a chance of one in ten billion that some two hashes have collided over the last 30 years. Your piece of toast, perhaps, and my bitcoin digest.

I think for practical purposes we're pretty safe.

[0]https://en.wikipedia.org/wiki/Birthday_problem

Re:String.hashCode() is plenty unique by lostmsu on Saturday August 11, 2018 @03:14PM (#17741086)
Impressively, my Facebook interviewer did not recognize validity of nearly identical explanation for using sha256 hashes instead of full strings as a key for purpose of counting stack traces.
Re:String.hashCode() is plenty unique by cm2187 on Saturday August 11, 2018 @06:54AM (#17739189)
I think you are assuming it has a perfectly uniform distribution.
Re:String.hashCode() is plenty unique by dmurray on Saturday August 11, 2018 @08:06AM (#17739366)
Yes, that's what I meant by saying sha256 is at least "pretty good" as a hash function. Which is not at all proven, but one of the reasons sha256 is popular is that it looks like it should be close to uniform.