Hashing is a method of cryptography that takes a message, for example ‘HELLOWORLD’ and converts it into a randomised text.
For example – ‘HELLOWORLD’ as a Hash function looks like this: ‘e81e26d88d62aba9ab55b632f25f117d’.
So this jumble of numbers and letters is the output of ‘hashing’ HELLOWORLD. The reason we hash something is to hide the message from preying eyes. Hashes are designed to be one way only, so if you give someone the hash of a message, they would not be able to reverse engineer it and come up with the original message, in our case ‘HELLOWORLD’.
Also two different inputs cannot result in the same output, if they did this would be called a ‘collision’. What we must also understand is that every time we hash ‘HELLOWORLD’ it will always produce the same hash output (e81e26d88d62aba9ab55b632f25f117d), this is known as a ‘deterministic’ hash function. In this example I am using the MD5 hashing algorithm, which is a type of cryptographic hash function.
What is the difference between hashing and encryption?
Encryption and hashing are often misunderstood as the same process, but this is incorrect. The easiest way to understand it is to break it down to use case. When we encrypt something we use keys (a key is a passphrase only you know) to enable us to decrypt it again. When we hash something we are more likely to be comparing hash outputs. So again using ‘HELLOWORLD’ as an example in the form of a password. If we want to hide our password we hash ‘HELLOWORLD’ and it produces e81e26d88d62aba9ab55b632f25f117d. If someone comes across this hash they will have no way to reverse engineer the password. When someone inputs a password later on, the system will hash it and if it doesn’t exactly match e81e26d88d62aba9ab55b632f25f117d then the system knows that the original string of text was not ‘HELLOWORLD’.