Hash Functions

Hash functions are algorithms to convert data, usually big data, into small data, where the same input data always gives the same output data. The input data can usually be of any size and the output data is of a fixed size. In computer science, this size is usually in bytes. The input data is called the message and the output data is called hash values, hash codes, checksums or simply hashes. This does mean that it is technically possible that different input data can result in the same output data. This is called a collision. But good hash functions are designed to make that chance as small as possible. With nowadays hash functions, the chance that you will find a collision is really small... really really small.

But where would you use such a thing for?

Comparison Tasks

If you normally would compare two shitloads of data it would take a long time. But if you already got the hash codes of both loads, then you can just compare the hash codes, which is way faster! If both hash codes are the same, than the original data is (most probably) the same. Again, the chance that the hash codes would be the same and the original data not, is minuscule, even microscopic with good hash functions.

Checksums

You could also use them as checksums. If you would get data (like when you download something for example), sometimes you might want to check its integrity. Maybe your downloaded file just got 1 bit wrong and is corrupted? If you could get the hash code of the original file, you could calculate the hash code of your download file and check it against the given hash code. If the hash codes are the same than your downloaded file is (most probably) correct.

I think those two task are most common for hash functions in computer science. But I think for Starcraft 2, you might not even need both! I wrote a tutorial though about using checksums to check the integrity of bank data: http://forums.sc2mapster.com/resources/tutorials/15368-trigger-securing-bank-data-with-checksums/#p7


Comments

Posts Quoted:
Reply
Clear All Quotes