In simple words, a hash function is a function that maps any arbitrary value to a certain fixed range.
For example, you may want to map the values from 1 to 100 within a range of 1 to 10. A simple way to do this would be to divide the range into 10 equal parts and map each to a single number. The diagram below demonstrates this:
Hash Functions are typically used in applications where data storage and retrieval requirements expect a constant time complexity. A good hash function is one that uniformly distributes data into different buckets.
Specialized hash functions that guarantee certain security properties are widely used in the field of cryptography and information security. For example, applications that need to verify the integrity of confidential data use a cryptographic hash function. Password verification and digital signature schemes also rely on such functions.
Such functions are often called one-way functions – it is practically infeasible to invert them, i.e., provided the output of the hash function, it should be infeasible to arrive at the input that produced the given output.
A slightly modified variant of FNV was used as the default hash function in Python.
It is widely used in zlib compression library.
RIPEMD is used in Bitcoin and related applications.
Scrypt is used as a password-based key derivation function for password hashing.
In many programming languages, a hashcode of an object is used to determine if two objects are equal.
Hash functions are employed in order to quickly verify if the element is a member of the set.
This is one of the most common applications of hash functions – it certifies to the user that the data is unchanged. However, it does not guarantee the originality of the file, so the attacker could potentially change both the file and the hash.
In the simplest verification scheme, the passwords are stored as a one way hash. When you enter your password, it is hashed and then the two hashes are compared to each other.