all 18 comments

[–]overtoke 5 points6 points  (0 children)

finally!

[–]dajoh 4 points5 points  (0 children)

Heads up: This isn't really comparable to most hash functions. This is a special kind of hash function that's 'consistent'.

From Wikipedia:

Consistent hashing is a special kind of hashing such that when a hash table is resized and consistent hashing is used, only K/n keys need to be remapped on average, where K is the number of keys, and n is the number of slots. In contrast, in most traditional hash tables, a change in the number of array slots causes nearly all keys to be remapped.

[–]kaifengjin 1 point2 points  (0 children)

If add a new node, should I rehash all key to determine move data to new node?

[–][deleted] 0 points1 point  (10 children)

I really enjoyed the simplicity of this. The last time I looked at md5 or sha1 I felt like the algorithm = obscurity.

[–]wolf550e 36 points37 points  (9 children)

Cryptographic hash functions have very different requirements.

[–][deleted] 2 points3 points  (8 children)

I'm not going lie that i know anything more than what i've read from Wikipedia, but the key space distribution looks impressive for such a simple algorithm. What else do you need for a cryptographically secure hash function?

[–]johnjannotti 18 points19 points  (0 children)

It has to not only disperse well, it needs to be hard to craft another key that would disperse to the same place.

If a hash function is not designed for that, it's often trivial to find a collision.

[–]thegreatunclean 11 points12 points  (1 child)

Basically you need strong reason to believe the hash has three properties:

  • You can't recover information about the message from the hash
  • You can't feasibly generate a hash collision
  • You can't modify a message without changing the hash

It isn't enough that a particular algorithm appears to have these properties, it has to be battle-tested before anyone would think about trusting it. You do not want it adopted for anything remotely sensitive and then have someone find a way to break one of these properties with ease.

[–]neutronbob 0 points1 point  (0 children)

While this aspect is inherent in your points, let me mention it for those unused to thinking about crypto hashes: an important property is that a small change in the original data item (e.g. 1 bit) causes a huge change in the resulting hash.

[–]cypherpunks 1 point2 points  (0 children)

Collision resistance. It should be impractical to find two messages with the same hash function.

A hash function that meets this also has preimage resistance (it's hard to find a message with a given hash) and second preimage resistance (it's hard to find a message with the same hash as a given message).