A hash function is a method originally created to compare files, sent from a server, to the files you received, to ensure data integrity of the downloaded files.
- All the data in the originating file is put through a specific algorithm to come up with an encrypted result. This encrypted result is noted and saved.
- The file is transmitted to you.
- You take that data and run the same algorithm over it, to get a result.
- You compare this result to the result from the first step.
- If they are equal, you received the exact data. If they are different, some packets have been dropped or the data has been manipulated and you need to receive the original file again.
This was the original use case of hashing. Hashes are used here for tying blockchains together.