Understanding Hashing: Simply yet, hashing can be considered a type of one-way encryption. More accurately, it is a process that creates a scrambled output that can’t be reversed—or at least can’t be revered easily.
The process of hashing takes plain text and transform it into cipher text but does so in such a way that it is not intended to be decrypted.
The process outputs what is known as a hash, hash value, or message digest. Below shows a hash created from the input “Hello World.”
Hash generated from “Hello World” using MD5
Designed to be a one-way process, hashing is commonly used to validate the integrity of information. A hash function generates a fixed-length value that is always the same length no matter how large or small the data entering the process or algorithm is.
The resulting output, as we already discussed, is intended to be nonreversible or very nearly impossible to reverse.
The fixed-length value is unique for every different input that enters the process. It is because of this unique property and its behavior that hashes are used to detect the changes that can happen in data of any type.
Hashing lets you easily detect changes in information: Anything that is hashed and then changed, even a small amount, will result in an entirely different hash from the original.
Hashed values are the result of information being compressed into the fixed-length value. A one-way hash function is also known as a thumbprint.
The following is a list of hashing algorithms currently in use:
Message Digest 2 (MD2): A one-way hash function used in the privacy-enhanced mail (PEM) protocols along with MD5.
Message Digest 4 (MD4): A one-way hash function used for PGP and other systems. MD4 has been replaced by MD5 in most cases.
Message Digest 5 (MD5): An improved and redesigned version of MD4 that produces a 128-bit hash. MD5 is still extremely popular in many circles, but it is being phased out due to weaknesses that have led to the system being vulnerable.
In many cases, MD5 has been replaced with SHA2.
Message Digest (MD6): A hashing algorithm that was designed by Ron Rivest.
HAVAL: A variable-length, one-way hash function and modification of MD5. The name is derived from the phrase “hash algorithm of variable length.”
RIPE-MD: A hashing algorithm commonly used in Europe.
Secure Hash Algorithm-0 (SHA-0): Used prior to SHA-1, it has since been replaced by SHA-1 and even SHA-2.
Secure Hash Algorithm-1 (SHA-1): One of the other more commonly used hashing algorithm. It has been compromised and is being replaced by SHA-2.
Secure Hash Algorithm-2 (SHA-2): Designed to be an upgrade to SHA-1, SHA-2 identifies the range of hash lengths above SHA-1 (SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224, and SHA-512/256).
Let’s look at an example of the hashing process. Say you have two parties, Sean and Zelda. Sean is the sender of the message and Zelda is the receiver:
- Sean creates a message.
- Sean hashes the message using an algorithm such as MD5 and SHA2.
- Sean encrypts the hash with his private key.
- Sean binds the encrypted bundle and the plaintext message together.
- Sean sends the combination to Zelda.
- Zelda sees that the message came from Sean.
- Seeing who the sender is, Zelda retrieves Sean’s public key from the CA they both trust.
- Zelda decrypts the encrypted hash value; it decrypts successfully, thus validating the identity of the sender (Sean).
- After the hash is decrypted, Zelda returns the MD5 algorithm against the plaintext message and compares the new hash with the one she received from Sean.
- If the two hashes match, the message has not been altered since Sean singed it.