๐Ÿ‹
Menu
How-To Beginner 2 min read 300 words

How to Generate and Validate Checksums

Create MD5, SHA-256, and other checksums for file integrity verification and understand when to use each algorithm.

Checksum Generation and Validation

Checksums verify that files haven't been modified or corrupted during transfer, storage, or processing. A single bit flip changes the checksum completely, making even minor corruption detectable.

How Checksums Work

A hash function processes a file of any size and produces a fixed-length string (the checksum). MD5 produces a 32-character hex string, SHA-256 produces a 64-character hex string. The same file always produces the same checksum. Even a single byte change produces a completely different checksum (the avalanche effect). This makes checksums reliable for detecting any modification.

Algorithm Selection

MD5 (128-bit): fast, widely used for quick integrity checks. Cryptographically broken โ€” don't use for security, but fine for detecting accidental corruption. SHA-256 (256-bit): the standard for security-relevant integrity verification. Used by package managers (npm, pip), certificate authorities, and blockchain. BLAKE3: faster than MD5 while being as secure as SHA-256. Newer, less universally supported.

Generating Checksums

Browser-based tools generate checksums locally โ€” drop a file, get the hash instantly. For command line: sha256sum filename (Linux/Mac). For verifying downloads, compare the generated checksum against the value published on the download page. Even one character difference means the file has been modified.

Verifying Downloaded Software

Software publishers provide checksums alongside downloads. After downloading, generate a checksum of your local file and compare it character-by-character against the published value. This detects: corrupted downloads (partial file), man-in-the-middle attacks (modified file), and mirror tampering (substituted file). If the checksums don't match, re-download from the official source.

Subresource Integrity (SRI)

For web development, SRI uses checksums to verify CDN-hosted scripts and stylesheets. Add an integrity attribute: