Back to the map

Module 02 · Networking · Lesson 7 of 7

Checksums and data integrity

Bits flip in transit and at rest more often than intuition says. Checksums, CRCs and cryptographic hashes detect corruption at different strengths and costs, and every storage and transfer system uses at least one.

IntroNice-to-knowJunior 8 min Updated Nov 2026

Why it matters

Networks drop and corrupt packets, disks rot, memory flips bits, and a bug in one service can truncate a file that six others then copy faithfully. At the scale of petabytes and billions of requests, "rare" events happen daily. A checksum is a few bytes that let the receiver know the data it got is the data that was sent. Every serious storage system, transfer protocol and backup scheme verifies integrity this way, and designs that skip it discover corruption only when a customer does.

The idea

A checksum is a small value computed from a block of data such that a change to the data almost certainly changes the value. The sender computes and attaches it; the receiver recomputes and compares. Equal means intact with high probability; different means corrupted, so retransmit, re-read from a replica or raise an alarm.

Data+ checksumtransfer or storeData'maybe alteredrecomputematch: acceptmismatch: retry
Compute at the source, carry alongside the data, recompute at the destination. A mismatch means the bytes changed on the way.

Three strengths, three costs

 Simple checksumCRCCryptographic hash
ExamplesInternet checksum (IP, TCP, UDP headers)CRC-32, CRC-32CSHA-256, BLAKE3, MD5 (legacy)
Size16 bits32 bits128–256 bits
DetectsRandom single errors; misses some swapsBursts of bit errors reliablyAny change, including deliberate tampering
SpeedTrivialVery fast, often hardware-acceleratedFast, but noticeably more CPU
UsePacket headersEthernet frames, ZIP, storage blocks, Kafka messagesContent addressing, downloads, deduplication, signatures
Match the strength to the threat: transmission noise needs a CRC; untrusted input needs a cryptographic hash.

A CRC catches the random errors networks and disks produce but can be forged by anyone who wants to; a cryptographic hash cannot be matched by a different input in practice, which is what makes it suitable for verifying downloads from an untrusted mirror or for addressing content by its hash.

Where you meet them in a design

  • Transport: TCP and UDP carry a checksum per segment; Ethernet carries a CRC per frame. Corrupt packets are dropped and TCP retransmits, which is one reason TCP's reliability works.
  • Storage: object stores return an ETag or explicit checksum on upload and verify it; file systems such as ZFS checksum every block and repair from a replica on mismatch, which is how they survive silent disk corruption.
  • Replication and backup: comparing hashes of blocks or files is how replicas detect divergence cheaply (Merkle trees, covered in Data structures for scale).
  • Content addressing: name a blob by its hash and you get deduplication, immutable caching and tamper evidence for free. Git, container registries and CDN asset versioning all rely on it.
  • APIs: an upload endpoint that accepts a client-computed hash and rejects a mismatch turns a silent corruption into a 400.

Trade-offs

Checksums cost CPU and a few bytes per block, both negligible against the data they protect, which is why the only real trade-off is strength versus speed. CRCs are cheap enough to run everywhere; cryptographic hashes are reserved for where tampering or deduplication matters. The practical failure is not cost but omission: pipelines that copy data without verifying it end to end.

In an interview

It is a detail, so spend it where it counts. In a file-upload or storage design: "The client sends a SHA-256 with the upload; the object store verifies it and we store the hash as the object's key, which gives us deduplication and lets the CDN cache immutably." In a replication design, mention comparing block hashes to detect divergence. One sentence, placed well, signals you have run data at scale.

Check yourself

A service lets users download software packages from third-party mirrors. Which integrity check should the client use, and why?

Checksums and data integrity · Backplane