What's this whole thing about?
What exactly is a cryptographic hash function?
A cryptographic hash function is a hash function which takes an input (or 'message') and returns a fixed-size alphanumeric string, which is called the hash value (sometimes called a message digest, a digital fingerprint, a digest or a checksum).
The ideal hash function has three main properties:
- 1. It is extremely easy to calculate a hash for any given data.
- 2. It is extremely computationally difficult to calculate an alphanumeric text that has a given hash.
- 3. It is extremely unlikely that two slightly different messages will have the same hash.
Functions with these properties are used as hash functions for a variety of purposes, not only in cryptography. Practical applications include message integrity checks, digital signatures, authentication, and various information security applications.
See? It's useful stuff.
Let me give you an easy example.
Let's say you register on this site (I mean we hope you do). A week later some naughty hacker steals everything from our database (won't happen, but let's assume it does for a second). Now you are in panic, because this guy now has your password. Or has he? It turns out that we do not store a single password in our database, only the hashes of the passwords. What does that mean? Well it means, that the hacker has no known way to get your password from the hash he found. Even if all data from our database were shared on the internet by this hacker, no password would be stolen. Now thats some cool stuff right there.