Skip to content
IGCSE·Tuition
Computer Science · Lesson

Use a checksum and know its limits

A checksum feels more powerful than parity, so it is tempting to describe it as a way of keeping data safe.

On this page
  1. How does a simple checksum work?
  2. Worked example
  3. What mistake do students make?
  4. Check yourself
  5. Where this leads next

A checksum is a number calculated from a block of data and sent with it. The receiver repeats the calculation. If the numbers differ, the block changed on the way, so the receiver rejects it.

Questions ask you to calculate a checksum, compare two values and say what the method can and cannot do. The words you choose matter as much as the sum.

This lesson comes after parity in data transmission and checking.

How does a simple checksum work?

To keep the arithmetic easy, this lesson uses a teaching version: add the values, then take the remainder after dividing by 100. Real checksums use different rules, so follow your syllabus and teacher for the version you must know.

  1. Add all the data values.
  2. Take the sum MOD 100 to get the checksum.
  3. Send the data and the checksum together.
  4. The receiver repeats steps 1 and 2 on the data that arrived and compares.

Worked example

Four data values are sent: 52, 87, 19, 66.

total ← 0
FOR i ← 1 TO 4
   total ← total + Data[i]
NEXT i
checksum ← total MOD 100

Trace:

iData[i]total
start0
15252
287139
319158
466224

Then 224 MOD 100 = 24. Check by hand: 52 + 87 = 139, 139 + 19 = 158, 158 + 66 = 224, and 224 − 200 = 24.

Receiver, case 1. The block arrives as 52, 87, 91, 66. The total is 296, and 296 MOD 100 = 96. This does not equal 24, so the receiver detects an error.

Receiver, case 2. The block arrives as 87, 52, 19, 66. The total is still 224, so the checksum is 24. The check passes even though two values swapped places.

What mistake do students make?

A common line is: “The checksum makes the data secure, so nobody can change it.”

This is wrong. A checksum is a way to detect accidental changes. Someone who deliberately alters the data can work out the new checksum and send it along, so the receiver would see a match. The honest wording is: “A checksum can detect many accidental errors, but it does not stop a person from changing the data on purpose, and it can miss some changes such as swapped values.”

Check yourself

1. Calculate the checksum (sum MOD 100) for 14, 35, 28, 9.

Show answer

14 + 35 = 49, 49 + 28 = 77, 77 + 9 = 86. 86 MOD 100 = 86.

2. The sender’s checksum was 95 for the values 40, 25, 30. The receiver gets 40, 25, 31. Does the check pass?

Show answer

40 + 25 + 31 = 96, so the receiver’s checksum is 96. It differs from 95, so an error is detected.

3. Give one reason a checksum is not a security feature.

Show answer

Anyone changing the data can recalculate the checksum and replace it, so the receiver would see a match. It only detects accidental changes.

Where this leads next

Finally, separate checks that only notice problems from methods that repair them in error detection versus correction. Use the safe Python reasoning sandbox to write the sum-and-remainder loop yourself and test it with the values above. Then try the practice set.

If you can do the sum but your evaluation answers sound vague, a teacher can tighten the wording with you in online one-to-one Computer Science tuition.

Questions people ask

What is a checksum?

A checksum is a value calculated from a block of data, sent along with it. The receiver calculates the value again from what arrived and compares. If the two values differ, the data changed in transit. Real systems use more complex calculations than the simple sum shown here.

Can a checksum protect data from hackers?

No. Anyone who changes the data can recalculate the checksum and replace it, so the receiver sees a match. A checksum is designed to notice accidental errors such as noise on a line. Protecting against deliberate changes needs other tools, such as encryption and digital signatures.

Is a checksum better than parity?

It covers a whole block rather than one byte, and a simple sum catches many single changes that a parity bit would miss. It still has gaps, for example when two values swap places. Treat it as a stronger check, not a perfect one.

Updated:

Your next step

If you want a second pair of eyes on how you word what a check can and cannot do, a one-to-one teacher can mark your explanation and sharpen it with you.

Paid one-hour trial at your assigned teacher’s confirmed rate, starting from RM80.

Tuition is arranged with a parent or guardian. Send them this page on WhatsApp and they can enquire for you.

Parents: enquire here

  • 9,000+ students helped through our service
  • 9+ years helping IGCSE students