What is a hash?
A hash is a function that converts one value to another…
hash("hello") = 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824hash("hbllo") = 58756879c05c68dfac9866712fad6a93f8146f337a69afe7dd238f3364946366hash("waltz") = c0e81794384491161f1777c232bc6bd9ec38f616560b120fda8e90f383853542
Let’s dig in?
If you’ve ever read anything about Bitcoin, passwords, or verifying software, you’ll have come across the word ‘hash’.
Hashes are essentially just fingerprints of a given input, whether that input is a file or a string of text.
The most important thing to understand about hashing is that if you make any change to the input, regardless of how minor it is, the hash (fingerprint) will change completely. Conversely, if you hash the exact same input multiple times, you will always get the same hash (output). This is extremely useful.
For example, if you want to send someone a file and make sure they receive it without it being tampered with, you can make a hash of that file, send the hash to them through another channel, and then they can hash the file they receive and compare it to the hash you sent. If the hash is different, then it isn’t the same file you sent them and someone might be up to something rather nefarious.
It’s easy to figure out what the ideal cryptographic hash function should be like:
- It should be fast to compute the hash value for any kind of data;
- It should be impossible to regenerate a message from its hash value (brute force attack as the only option);
- It should be infeasible to find two messages with the same hash (a collision);
- Every change to a message, even the smallest one, should change the hash value. It should be completely different. It’s called the avalanche effect.
Summary:
- Hashes take an input and provide an output of a fixed length.
- It is easy to determine the output if you only have the input, but it is incredibly hard to determine the input if you only have the output.
- If you can determine the input from the output faster than just making a bunch of random guesses, the hash algorithm is considered weak, if not broken.
- Hashes can be useful for both verifying that files haven’t changed, as well as for protecting passwords. But these are just two common uses for hashes out of many, many others.
If you want to learn more check the link below…