CMD Guide
HomeSystem DesignChecksum

Uses of Checksum

A checksum works because a small, fixed-size number is derived deterministically from every bit of a payload, so the receiver (or the storage layer) can recompute that number from the bytes it actually holds and compare: if a single bit changed anywhere, the recomputed value almost certainly won't match, and the mismatch is the signal that the data is no longer what was written or sent.

Everything checksums are "used for" is one variation on that recompute-and-compare loop. What differs from use to use is who recomputes, when, and what threat the comparison is meant to catch — and that last point is where most real-world mistakes (including the classic password myth) come from.

diagram
diagram

A worked trace: the 16-bit Internet checksum

This is the checksum in IPv4, TCP, and UDP headers (RFC 1071). It is a one's-complement sum: add the 16-bit words, and whenever the running total overflows 16 bits, add the carry bit back in ("end-around carry"). The sender stores the complement of that sum, chosen so that the receiver's total — data plus stored checksum — comes out to all ones.

Take four data words: 0x0001, 0xF203, 0xF4F5, 0xF6F7.

StepAddRunning totalAfter end-around carry
10x00010x00010x0001
2+ 0xF2030xF2040xF204
3+ 0xF4F50x1E6F90xE6F9 + 1 = 0xE6FA
4+ 0xF6F70x1DDF10xDDF1 + 1 = 0xDDF2

Folded sum = 0xDDF2. The transmitted checksum is its one's complement: ~0xDDF2 = 0x220D.

Clean receive. The receiver sums the four data words and the checksum: 0xDDF2 + 0x220D = 0xFFFF. Complement is 0x0000 → no error, accept.

One flipped bit. Suppose 0xF4F5 arrives as 0xF4D5 (one bit flipped). The data now folds to 0xDDD2; adding the unchanged checksum gives 0xDDD2 + 0x220D = 0xFFDF, whose complement is 0x0020 ≠ 0 → error detected, reject. That single non-zero result is the entire value the checksum delivers.

Where this loop actually shows up

The legitimate uses collapse into three families, each just relocating "who recomputes and when":

Fixing the password myth (why the naive version is wrong)

The original page claimed systems “store the checksum of a password instead of the password.” Storing a bare digest of a password is a real, exploited vulnerability, and a checksum is the wrong primitive for three independent reasons:

Correct statement: passwords are stored as a salted, slow key-derivation hash (Argon2id today), not a checksum. The login flow superficially resembles recompute-and-compare, but the threat model is an adversary with your database, not a flipped bit — and that changes the required primitive entirely.

When to use it, and when NOT to

Reach for a plain checksum (CRC32, Adler-32, Internet checksum) when the signal you're chasing is accidental corruption from noisy channels, cosmic rays, or aging disks, and you want detection that costs almost nothing per byte. The decision hinges on one question: is the party who might alter the data an adversary, or just physics?

PrimitiveExampleCatches random corruptionCatches deliberate tamperingRight for passwordsCost
ChecksumCRC32, Internet checksumYesNo (attacker recomputes it freely)NoTrivial
Cryptographic hashSHA-256, BLAKE3YesPartly — only if the digest is delivered over a trusted channelNoCheap
MAC / HMACHMAC-SHA256YesYes — needs the secret key to forgeNoCheap + key mgmt
Password KDFArgon2id, bcryptn/aYes, and resists offline crackingYesDeliberately slow

Choose a checksum when the enemy is noise and you control both ends — TCP segments, disk blocks, backup integrity. Prefer a cryptographic hash when an attacker might substitute a lookalike file and you can publish the expected digest somewhere they can't touch (a signed release page). Prefer HMAC or a signature when the attacker can also see and rewrite the digest in flight — a checksum or bare hash gives zero protection there, because they simply recompute it over their forged payload. Prefer a password KDF the moment the secret is a human password. Using CRC32 where you needed HMAC is a real breach class, not a micro-optimization.

Pitfalls

Takeaways


Re-authored and deepened for this guide. Worked example follows RFC 1071 (“Computing the Internet Checksum”); CRC behavior from Koopman's cyclic-redundancy-check work; storage-integrity examples from the ZFS and PostgreSQL documentation; password-storage guidance from OWASP's Password Storage Cheat Sheet and the Argon2 (RFC 9106) and bcrypt specifications. The password-verification claim in the original page was incorrect and has been replaced.

🤖 Don't fully get this? Learn it with Claude

Stuck on Uses of Checksum? Open Claude, copy a block below, and it'll teach you this exact concept — visually and interactively.

🎨 Explain it visually

Build the mental picture, not memorization.

I just read a lesson on **Uses of Checksum** (System Design) and want to truly understand it. Explain Uses of Checksum from first principles using ONE vivid real-world analogy and a visual mental model — draw it as ASCII art or a clear step-by-step diagram — with a concrete example using real numbers. Then ask me one question to check I got the mental picture, and wait for my reply. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🤔 Walk me through it (interactive)

Socratic — adapts to where you're stuck.

Teach me **Uses of Checksum** interactively. Ask me ONE guiding question at a time, wait for my answer, and adapt to my confusion — build the idea with me step by step instead of explaining it all at once. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧪 Quiz me & fix my gaps

Active recall exposes what you missed.

Quiz me on **Uses of Checksum** with 5 questions, easy to tricky, ONE at a time. Tell me if each answer is right; at the end, explain clearly what I got wrong and why. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧠 Make it stick

Intuition + hook + flashcards for long-term memory.

Help me remember **Uses of Checksum** for the long term: give the one-sentence intuition, a memorable hook/mnemonic, a tiny worked example, and 3 active-recall flashcards (Q -> A). If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.

📝 My notes