Hashing
Hashing is a transformation of variable-sized input data to a fixed-size output. This output is often called a hash, or a digest.
Perhaps the most important thing about hashing is that it only works in one direction. It is easy to take arbitrary input and produce a hash, but it is difficult to take a hash and produce the original input. This property of being one-way is what makes hashing so useful.
Another essential property of hashing is that even the smallest change in the input data can greatly change the resulting digest, making it Collision-resistant. Because of this, hashing is typically used to verify the integrity of some input data.
There are many common hashing algorithms:
- MD5 (1992): was too weak, first proper collision found 2017
- SHA-1 (1995): was also too weak
- SHA-2 (2001): so now we’re here, but Length Extension Attack is possible
- SHA-3 (2015): this is a completely different algorithm to SHA-2 to have as a backup (just to be safe)
Common applications of hashes include:
- comparing two files to verify if they are identical
- using checksums to prove the integrity of the transmitted data
Relevant Note(s): Salting