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: md5sum, sha1sum, sha256sum, sha512sum

Algorithm Cleartext Hash
MD5 beans 83490687e22073309e516a1c02b974eb
SHA1 beans b60efdd7fb69c8ef063935f4d7eddad40eb82ee4
SHA256 beans 4c6104ff17b3b4fcc9cfb40f9db70bc317023a71a529b30ee14c4a0844677f83
SHA512 beans 25ce77937cefb2b7f06ca7042536ff010b811afd5d3530301dce6a0ec891a28bfb5daae64f9046e45bcacaf961c0304a1c4a11f4ba614567cd614951c6fa5042

TL;DR (Summary)

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.