Checksum
A checksum is a small, fixed-size value computed from a block of data by a checksum algorithm and transmitted or stored alongside the data. The recipient recomputes the checksum over the received data and compares it to the original value. A match indicates the data is intact; a mismatch signals that the data was altered or damaged in transit.
Checksums exist to detect accidental corruption – bit flips, dropped or duplicated bytes, transmission noise – not deliberate tampering. Simple checksum algorithms have known collisions and can be forged by an attacker who knows the algorithm. Detecting intentional modification requires a cryptographic hash keyed with a secret or signature.
The algorithm is a form of hash function: it maps arbitrarily large input to a small, bounded output, so collisions are possible but made unlikely enough for the intended error-detection guarantee. The sender computes the value once, sends both the data and the checksum, and the receiver applies the same algorithm to the received data. If the two values agree, the data is accepted; otherwise it is discarded or requested again.
Common algorithms
- Sum and XOR checksums. The simplest schemes add or XOR the data bytes together. They are fast but weak, and miss many common errors such as reordered bytes.
- Cyclic redundancy check (CRC). A polynomial division over the data. CRC variants such as CRC-32 and CRC-16 are widely used in network protocols and storage because they detect burst errors well.
- Fletcher’s checksum and Adler-32. Used in zlib and other compression formats; stronger than a plain sum while remaining cheap to compute.
- Cryptographic hashes. Functions such as SHA-256 produce a strong digest that resists deliberate tampering as well as accidental corruption. They are the basis of the checksums published for file downloads and software releases.
Where checksums appear
- Network protocols. Both TCP and UDP carry a checksum over their header and payload so that corrupted segments are detected and dropped.
- File verification. Software distributions publish a checksum (often SHA-256) alongside each file so that downloaders can confirm the file was not altered.
- Storage. Filesystems and RAID arrays checksum blocks to detect silent corruption such as bit rot on disk.
Checksums are one of the basic techniques for data integrity, alongside transactions and replication.
See also
- Hashing: The family of functions checksum algorithms belong to.
- Data integrity: The broader goal checksums serve.
- Cryptography: Cryptographic hash functions provide tamper-resistant checksums.
- TCP: Carries a checksum over every segment.
- UDP: Carries a checksum over every datagram.
References
- Algomaster. What are checksums?. https://blog.algomaster.io/p/what-are-checksums
- Bradley Mitchell. What does checksum mean?. Lifewire. https://www.lifewire.com/what-does-checksum-mean-2625825