Reading — step 1 of 5
Read
Adler-32 & CRC-32
Compressed files are FRAGILE: a single bit flip in compressed data can corrupt megabytes of decompressed output. So all real compression formats include checksums:
Adler-32 (used by zlib): two 16-bit accumulators, a fast modular sum.
Pros: very fast (no table lookups, no bit operations besides shift). Cons: weak — small bit changes can produce same checksum.
CRC-32 (used by gzip, ZIP, PNG): polynomial division over GF(2).
Pros: detects all 1-2 bit errors and many burst errors. Standard. Cons: ~10x slower than Adler-32 unless you use a precomputed 256-entry table (which is the standard implementation — much faster).
Modern alternatives: xxHash, MurmurHash, Blake3 — non-cryptographic hashes that are fast AND collision-resistant. Used by zstd and modern formats.
For our purposes, just including a checksum at the end of the compressed stream lets the decoder verify the result.
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…