A hashing function maps some input data to a (smaller) output data set.
A very simple hashing function takes the input data and does a modulous operator on it.
Consider for example, office numbers and a simple hash function:
Input (office number) | Hash function | Output |
---|---|---|
245 | 245 mod 10 | 5 |
248 | 248 mod 10 | 8 |
253 | 253 mod 10 | 3 |
When two input values hash to the same output value, we call it a “collision”. Good hashing functions minimize collisions as well as the overall number of buckets.
In databases, hash functions are useful to quickly look up data records given an input key value.
In cryptography, hash functions are used to create message digests, digital signatures, responses to authentication challenges, etc.