What is the difference between a Hash Function and a Cryptographic Hash Function?

Technology CommunityCategory: Hash TablesWhat is the difference between a Hash Function and a Cryptographic Hash Function?
VietMX Staff asked 3 years ago

Every cryptographic hash function is a hash function. But not every hash function is a cryptographic hash.

The ideal cryptographic hash function has six main properties:

  1. Deterministic: the same message always results in the same hash;
  2. Quick: it is quick to compute the hash value for any given message;
  3. One-way function: it is infeasible to generate a message from its hash value except by trying all possible messages;
  4. Avalanche effect: a small change to a message should change the hash value so extensively that the new hash value appears uncorrelated with the old hash value;
  5. Collision resistant
    • weak collision resistance (given a message m1 it must be difficult to find a different message m2 so that m1 and m2 yield the same hash)
    • strong collision resistance (it should be difficult to find any messages m1 and m2 that yield the same hash)
  6. Pre-image attack resistant: given a hash h it must be difficult to find a message m that yields h when hashed. A cryptographic hash function should resist attacks on its pre-image.

Non cryptographic hash functions just try to avoid collisions for non malicious input. In exchange for weaker guarantees they are typically (much) faster.