Explain the differences as well as the similarities between Checksum vs Hash?

6.9K    Asked by AndrewJenkins in SQL Server , Asked on Dec 14, 2021

What are the Similarities & differences between the Checksum Algorithm and the Hash Function? can they be used in place of one another or is 

Is their usage different from each other? 

I reviewed many articles on web and came across an article that says -

A checksum is intended to verify (check) the integrity of data and identify data-transmission errors, while a hash is designed to create a unique digital fingerprint of the data. A checksum protects against accidental changes. A cryptographic hash protects against a very motivated attacker.


Answered by Ankit Chauhan

To properly understand the differences & similarities between Checksum vs Hash, we need to understand both simultaneously.


A checksum is used to determine if something is the same. If you have downloaded a file, you can never be sure if it got corrupted on the way to your machine. You can use cksum to calculate a checksum (based on CRC-32) of the copy you now have and can then compare it to the checksum the file should have. This is how you check for file integrity.

A hash function is used to map data to other data of fixed size. A perfect hash function is injective, so there are no collisions. Every input has one fixed output. A cryptographic hash function is used for verification. With a cryptographic hash function you should not be able to compute the original input. A very common use case is password hashing. This allows the verification of a password without having to save the password itself. A service provider only saves a hash of a password and is not able to compute the original password. If the database of password hashes gets compromised, an attacker should not be able to compute these passwords as well. This is not the case, because there are strong and weak algorithms for password hashing. You can find more on that on this very site.

TL;DR: Checksums are used to compare two pieces of information to check if two parties have exactly the same thing. Hashes are used (in cryptography) to verify something, but this time, deliberately only one party has access to the data that has to be verified, while the other party only has access to the hash.




Your Answer

Interviews

Parent Categories