Mathwords logoMathwords

Checksum — Definition, Formula & Example

A checksum is a small value calculated from a block of data and stored alongside it, so you can later recompute it and spot accidental changes. When the checksum is a single digit added to an ID number, such as an ISBN or a credit card number, it is called a check digit.

A checksum is a function c:Σn→Σkc: \Sigma^n \to \Sigma^k, with kk much smaller than nn, that maps a message mm to a short check value c(m)c(m). The sender transmits (m,c(m))(m, c(m)). The receiver accepts a received pair (m′,v′)(m', v') only if c(m′)=v′c(m') = v'. A check digit is the case k=1k = 1, and it is usually defined by a weighted sum of the digits, reduced modulo a fixed integer.

Key Formula

∑i=110(11−i) di≡0(mod11)\sum_{i=1}^{10} (11 - i)\, d_i \equiv 0 \pmod{11}
Where:
  • did_i = The i-th digit of the ISBN-10, read from left to right. The check digit d_10 may equal 10, which is written as X.
  • 11−i11 - i = The weight of position i. The weights run 10, 9, ..., 1.
  • (mod11)\pmod{11} = The weighted sum must leave a remainder of 0 when you divide it by 11.

Worked Example

Problem: Find the check digit for the ISBN-10 that begins 0-306-40615.
Step 1: Multiply the first nine digits by the weights 10 down to 2, then add the products.
0(10)+3(9)+0(8)+6(7)+4(6)+0(5)+6(4)+1(3)+5(2)=1300(10)+3(9)+0(8)+6(7)+4(6)+0(5)+6(4)+1(3)+5(2) = 130
Step 2: Reduce the sum modulo 11.
130=11⋅11+9,so 130≡9(mod11)130 = 11 \cdot 11 + 9, \quad \text{so } 130 \equiv 9 \pmod{11}
Step 3: The check digit has weight 1. You need 130 + d_10 to be a multiple of 11, and 9 + 2 = 11, so the check digit is 2.
d10≡−130≡2(mod11),130+2=132=11⋅12d_{10} \equiv -130 \equiv 2 \pmod{11}, \qquad 130 + 2 = 132 = 11 \cdot 12
Answer: The check digit is 2, so the full ISBN is 0-306-40615-2.

Why It Matters

The ISBN-10 scheme works modulo the prime 11. Because 11 is prime, it catches every single-digit error and every swap of two digits, including swaps of digits that are not next to each other. Credit cards use the Luhn algorithm (mod 10), and internet protocols such as TCP attach checksums to every packet. These schemes are the first examples you meet in a coding theory course, before you move on to error-correcting codes such as Hamming codes.

Common Mistakes

Mistake: Assuming that a matching checksum proves the data is correct, or that it protects against tampering.
Correction: A checksum detects only certain kinds of accidental errors. Two different messages can share the same checksum, and anyone who changes the data can simply recompute it. For deliberate tampering you need a cryptographic hash or a message authentication code.

Related Terms

  • Remainder — Check digits are remainders after division
  • Modulo — Operation that reduces the weighted sum
  • Digit — Checksums are computed from individual digits
  • Parity — Parity bit is the simplest checksum
  • Modular Arithmetic — Most checksums are computed with arithmetic mod n