An overview of hashing functions
Before we jump into the code, it's worth spending a few moments explaining what hashing functions are, how they are different from ciphers (which are functions that are used to encrypt and decrypt data), and their properties and uses.
Properties of hashing functions, and how they differ from encryption
While encryption is a two-way operation (you can encrypt a message and then decrypt it to get the original message once again), hashing is just one-way. That is, after you hash a message, you cannot retrieve the original plaintext in any way.
There are five defining characteristics of modern hashing functions:
- As we mentioned previously, you cannot retrieve the original message from its hash (also called a digest) as hashing functions are designed as one-way operations.
- Regardless of the size of the input message, the output hash has a fixed length. For example, SHA-256 hashes are always 32 bytes (256-bit) long, regardless of...