Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fastest Hash Algorithm for Text Data

I'm trying to choose a hash algorithm for comparing about max 20 different text data.

Which hash is better for these requirements?

  • Less CPU Consumption
  • Small footprint (<=32 bytes)
  • Collision is not a big deal
  • Can be generated from .NET Framework 2 (shouldn't be a 3rd party library)

I'm using hash for less memory footprint and comparison performance

like image 876
dr. evil Avatar asked Dec 21 '08 19:12

dr. evil


People also ask

Which hashing algorithm is the fastest?

SHA-1 is fastest hashing function with ~587.9 ms per 1M operations for short strings and 881.7 ms per 1M for longer strings. MD5 is 7.6% slower than SHA-1 for short strings and 1.3% for longer strings. SHA-256 is 15.5% slower than SHA-1 for short strings and 23.4% for longer strings.

Which is faster SHA-256 or MD5?

MD5 is known to be generally faster than SHA256 .

Is CRC32 faster than MD5?

Save this answer. Show activity on this post. If you want to check if two files are the same, CRC32 checksum is the way to go because it's faster than MD5. But be careful: CRC only reliably tells you if the binaries are different; it doesn't tell you if they're identical.

Which algorithm is best for hashing?

SHA-256: This hashing algorithm is a variant of the SHA2 hashing algorithm, recommended and approved by the National Institute of Standards and Technology (NIST). It generates a 256-bit hash value. Even if it's 30% slower than the previous algorithms, it's more complicated, thus, it's more secure.


2 Answers

If collision is not a big deal you can take the first letter of each document. Or you can use the length of the text or the string with the text.

like image 176
tuinstoel Avatar answered Sep 19 '22 14:09

tuinstoel


Paul Hsieh has a decent, simple, fast, 32-bit SuperFastHash that performs better than most existing hash functions, is easier to understand/implement, and sounds like it meets your criteria.

like image 40
Robert Gamble Avatar answered Sep 17 '22 14:09

Robert Gamble