A hash function is any function that can be used to map data of arbitrary size to data of fixed size.
In Programming 3, you will learn about hash functions and their relevance to data structures. A popular use of hash functions is to identify data and verify integrity. The integrity of downloads from the internet can be assured by computing a hash of the file, and comparing it against the checksum. If you visit the Kali Linux downloads page, you’ll notice that checksums are listed next to their respective ISOs.
A cryptographic hash function is a special class of hash function that has certain properties which make it suitable for use in cryptography. It is a mathematical algorithm that maps data of arbitrary size to a bit string of a fixed size (a hash) and is designed to be a one-way function, that is, a function which is infeasible to invert. The only way to recreate the input data from an ideal cryptographic hash function’s output is to attempt a brute-force search of possible inputs to see if they produce a match, or use a rainbow table of matched hashes.
The most popular cryptographic hash function is the Secure Hash Algorithm (SHA), developed by NIST. Even though its less secure, MD5 (Message Digest version 5) is also very popular.
To compute hashes on Linux, simply run the corresponding command:
A hash function (eg. MD5, SHA) generates a string of characters (eg. 83490687e22073309e516a1c02b974eb) from any kind of data (text, image…). This is a one-way function, trying to guess the original data from a hash is infeasible.