A checksum is a numerical value calculated from a block of data and transmitted alongside it. When data arrives, the receiver recalculates the checksum from the received data and compares it with the transmitted value — any mismatch signals that an error occurred. Checksums are widely used in file transfers, network packets, and storage systems.

Why do we need error detection?

Data travels across noisy physical media — copper cables, radio waves, optical fibres. Every medium introduces small risks of corruption: a power surge, electromagnetic interference, or even cosmic rays can flip a bit from 0 to 1 or vice versa. In most situations, a single flipped bit changes the meaning of data profoundly — altering a price, a medical dose, or a program instruction.

Turing recognised early that reliable computation requires reliable data. Error detection is the mechanism by which a receiver can tell whether the data it received is the same as the data that was sent. Detection alone does not fix the problem — it simply signals that something went wrong, so the receiver can ask for the data to be resent.

How is a simple checksum calculated?

The simplest checksum sums the numeric values of each byte (or a group of bytes) in the data block and stores the result, often taking only the remainder after dividing by a power of 2 (modular arithmetic).

Worked example — calculate a one-byte checksum for the data [42, 15, 87, 33]:

  1. Sum all byte values: 42 + 15 + 87 + 33 = 177
  2. If the checksum is constrained to one byte (0–255), the checksum is 177 directly — no remainder needed (177 < 256).
  3. The sender transmits: [42, 15, 87, 33, 177]

Verification at the receiver's end:

The receiver sums the data bytes: 42 + 15 + 87 + 33 = 177. Compare with the received checksum: 177 = 177. ✓ No error detected.

Example with an error:

Suppose bit corruption changes 15 to 14 during transmission. The receiver receives [42, 14, 87, 33, 177]. The receiver calculates: 42 + 14 + 87 + 33 = 176. 176 ≠ 177. ✗ Error detected. The receiver knows the data was corrupted and requests a retransmission.

Modular checksum example:

If the checksum field is limited to 4 bits (0–15), take the sum modulo 16: Sum = 177; 177 mod 16 = 1 (since 177 = 11 × 16 + 1). Transmitted checksum: 1. Receiver recalculates: same sum → same remainder → matches.

What errors can a checksum detect — and what can it miss?

A simple sum checksum detects most single-bit errors. However, it has weaknesses:

Error type Detected by simple sum checksum?
Single bit flip Usually yes
Burst errors (multiple adjacent bits) Often yes, but not always
Transposed bytes (e.g., 15, 42 instead of 42, 15) No — the sum is unchanged by reordering
Multiple bit flips that cancel out No — net change to sum is zero

Because addition is commutative (42 + 15 = 15 + 42), a simple checksum cannot detect reordering of bytes. More sophisticated algorithms — such as CRC (Cyclic Redundancy Check) — address this weakness.

How does a checksum differ from a parity bit?

Both checksums and parity bits are error detection mechanisms, but they differ in scope and power:

Feature Parity bit Checksum
Data scope One byte (7 data bits) A block of many bytes
What is added One extra bit One extra byte (or more)
Detects Single-bit errors only Most single and many multi-bit errors
Used in Serial data transmission, DRAM Network packets, file transfers, storage

A parity bit is the simplest possible checksum — it checks only whether the number of 1-bits in a byte is even or odd. A multi-byte checksum can protect much larger blocks of data.

What is a CRC and how is it different from a simple sum?

A CRC (Cyclic Redundancy Check) is a more powerful error detection algorithm that treats the data as a binary polynomial and divides it by a fixed "generator polynomial", using the remainder as the checksum. CRC can detect:

  • All single-bit errors.
  • All burst errors up to the length of the CRC (typically 16 or 32 bits).
  • Many byte-transposition errors.

CRC-32 is used in Ethernet, ZIP files, and PNG images. At GCSE level, you are expected to understand what a checksum does conceptually and how the basic mechanism works — the detailed mathematics of CRC is studied at university level.

Where are checksums used in practice?

Application Checksum / algorithm
Ethernet frames CRC-32
TCP/UDP packets Internet checksum (16-bit one's complement sum)
ZIP and PNG files CRC-32
Hard drive sectors CRC-32 or ECC (Error-Correcting Code)
Credit card numbers Luhn algorithm (a weighted checksum)
ISBN book numbers Weighted modulo-11 checksum

The Luhn algorithm — used for credit card number validation — is a well-known example of a simple checksum. Summing every other digit, doubling the rest, and checking the total modulo 10 catches most data entry errors and simple forgeries. An ISBN has a similar check digit for the same reason.

Frequently asked questions

What is the difference between error detection and error correction?

Error detection identifies that data has been corrupted, but does not fix it. The standard response is to request a retransmission. Error correction — using algorithms such as Hamming codes or Reed-Solomon — can identify exactly which bit was flipped and correct it without retransmission. Error correction requires sending significantly more redundant data (more overhead), so it is used where retransmission is impossible or too slow — for example, on CDs, DVDs, and satellite links.

Can a checksum guarantee that data arrived without errors?

No. A checksum can detect most errors, but not all. Two different data blocks can theoretically produce the same checksum (called a collision). If corruption happens to change data in a way that the sum is unchanged (for example, two different bytes each change by opposite amounts), the error goes undetected. The probability of an undetected error depends on the length and algorithm used — CRC-32 misses fewer than 1 in 4 billion random errors.

Is hashing the same as a checksum?

A cryptographic hash (such as SHA-256) is a much stronger version of the same concept: a fixed-length output derived from the input data. Like a checksum, a hash changes if any bit of the data changes. Unlike a simple sum checksum, a cryptographic hash is designed to be computationally infeasible to reverse or to find a collision deliberately. Checksums are for accidental error detection; cryptographic hashes are for intentional tampering detection (data integrity in security contexts).

How would you calculate a checksum in Python?

A simple sum checksum: sum(data) % 256 where data is a list of integer byte values. To verify, append the checksum to the data, sum all values including the checksum byte, and check whether the result modulo 256 equals zero (an alternative formulation where the checksum is chosen to make the total sum to 0 mod 256). This kind of exercise — implementing and testing a checksum — is a common GCSE programming task.


Work through data integrity and error detection problems with Professor Turing's guided tutoring at aitutors.me.