Skip to main content
Software Engineering

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Which hashing algorithm is best for uniqueness and speed?

Which hashing algorithm is best for uniqueness and speed? Example (good) uses include hash dictionaries.

I know there are things like SHA-256 and such, but these algorithms are designed to be secure, which usually means they are slower than algorithms that are less unique. I want a hash algorithm designed to be fast, yet remain fairly unique to avoid collisions.

Answer*

Draft saved
Draft discarded
Cancel
7
  • 61
    It's relatively fast, sure, for a cryptographic hashing algorithm. But the OP just wants to store values in a hashtable, and I don't think a cryptographic hash function is really appropriate for that. Commented Feb 19, 2011 at 1:10
  • 6
    The question brought up (tangentially, it now appears) the subject of the cryptographic hash functions. That's the bit I am responding to. Commented Feb 22, 2011 at 13:14
  • 18
    Just to put people off the idea of "In particular, a common technique for storing a password-derived token is to run a standard fast hash algorithm 10,000 times" -- while common, that's just plain stupid. There are algorithms designed for these scenarios, e.g., bcrypt. Use the right tools. Commented Oct 14, 2013 at 13:19
  • 3
    Cryptographic hashes are designed to have a high throughput, but that often means they have high setup, teardown, .rodata and/or state costs. When you want an algorithm for a hashtable, you usually have very short keys, and lots of them, but do not need the additional guarantees of a cryptographic has. I use a tweaked Jenkins’ one-at-a-time myself. Commented Dec 6, 2013 at 13:57
  • 1
    @ChrisMorgan: rather than using a cryptographically secure hash, HashTable DoS can be solved much more efficiently using hash randomization, so that every run of the programs or even on every hashtable, so the data doesn't get grouped into the same bucket every time. Commented Nov 12, 2017 at 17:16

AltStyle によって変換されたページ (->オリジナル) /