Data Integrity and Checksums: How Storage Detects Corruption
A file can change without anyone touching it. A single flipped bit on a disk, a glitch in memory during a copy, or a faulty cable can alter data quietly. Nothing crashes and no warning appears. You only find out months later, when a photo will not open or an archive refuses to unpack.
This quiet damage is called silent data corruption or bit rot. The standard defense is a checksum: a small value computed from the data that lets you notice when the data no longer matches.
What a checksum is
A checksum is a short, fixed-size value calculated from a block of data using a mathematical function. If you calculate it again later and the result differs from the stored one, the data has changed. It does not tell you what changed or how to fix it, only that something did.
Think of it as a tamper seal. The seal says nothing about the contents, but a broken seal tells you to be suspicious.
Simple checksums versus cryptographic hashes
There is a range of functions, with different strengths:
- Parity bit: a single extra bit that flags whether the number of ones is odd or even. It catches some single-bit errors but misses many others.
- CRC (cyclic redundancy check): a fast function widely used in storage, networking and file formats. It is excellent at catching accidental errors such as burst errors from noise.
- Cryptographic hash (SHA-256 and similar): designed so that finding two different inputs with the same output is computationally impractical. These are used when you also need to resist deliberate tampering.
For catching random damage, a CRC is often enough. For verifying downloads or detecting deliberate changes, a cryptographic hash is the better choice.
Where checksums are used in storage
Checksums appear at several levels of a storage system:
- Inside the drive: each sector is stored with extra data used for error detection and correction, so the drive can fix small errors before your computer sees them.
- On the connection: interfaces use their own checks to catch damage during transfer between drive and computer.
- In the file system: some modern file systems store a checksum for every block of data and metadata, and verify it on each read.
- In applications: archive formats, backup tools and download pages publish hashes so you can confirm a file is intact.
Detection versus correction
Detecting an error and fixing it are different jobs. An error correcting code stores extra redundant information so that small errors can be repaired automatically. Drives and memory modules use these constantly, and you rarely notice.
When corruption exceeds what the code can repair, the device may report a read error. A checksum alone can only flag the problem. To repair the data you need another good copy, such as a mirror in a RAID array or a backup.
Self-healing file systems
Certain file systems combine checksums with redundancy. When they read a block, they verify its checksum. If it fails and a mirrored or parity copy exists, they fetch the good copy, return it to the program, and rewrite the damaged one. This is often called self-healing.
These systems also offer a scrub operation. A scrub reads through all stored data in the background, checks every checksum, and repairs what it can. Running scrubs on a regular schedule finds problems before the last good copy is gone.
Verifying your own files
You do not need special storage to benefit from checksums. Most operating systems include command-line tools that calculate hashes. After creating a backup or downloading a large file, you can compare its hash with a known good value.
On Linux and macOS, a common approach looks like this:
sha256sum archive.zip
On Windows, PowerShell offers a similar command:
Get-FileHash archive.zip -Algorithm SHA256
If the output matches the value published by the source, the file is intact. A single changed bit produces a completely different result, so an exact match is meaningful.
Building a habit around integrity
A reasonable routine for personal archives looks like this:
- Generate hashes for important folders when you first store them.
- Save the list of hashes in a separate location from the files.
- Recheck on a schedule, perhaps once or twice a year.
- If a file fails, restore it from another copy and investigate the drive.
The same idea applies after a large copy. Comparing hashes between source and destination catches errors from a flaky cable or failing drive that a simple file count would miss.
Limits to remember
Checksums cannot protect you from deleting a file or from corruption that happened before the checksum was recorded. If a file was already damaged when you hashed it, the hash simply confirms the damaged version. Keep the hash list safe too, since a corrupted list gives false alarms.
Frequently Asked Questions
What is bit rot?
Bit rot is the gradual, unnoticed corruption of stored data, caused by things like media decay, cosmic rays, or hardware faults. It is usually detected only when a checksum no longer matches or a file fails to open.
Is MD5 still fine for checking files?
For detecting accidental corruption, MD5 still works. It is no longer considered safe against deliberate tampering, because researchers have found ways to create different files with the same hash. For anything security related, use SHA-256.
Do SSDs have error checking too?
Yes. SSD controllers use strong error correcting codes on every page of flash, because flash cells naturally produce some errors. These codes quietly repair small mistakes before the data reaches your computer.