Notes for checksum
2025-02-13
Checksums
A checksum is a short, fixed-length value calculated from a file's contents using a hash function (such as MD5, SHA-1, or SHA-256). The main objective of a checksum is to verify data integrity—ensuring that a file has not been altered, corrupted, or tampered with during transfer or storage.
Why Use Checksums?
- Integrity Verification: Detect accidental or malicious changes to files.
- File Comparison: Quickly check if two files are identical without comparing their entire contents.
- Data Security: Ensure downloaded files are authentic and unmodified.
How Are Checksums Calculated?
A hash algorithm processes the file's data and produces a unique value (the checksum). Even a tiny change in the file will result in a completely different checksum. Renaming a file does not affect its checksum, as only the content matters.
Example: Calculate a Checksum in PowerShell
Get-FileHash -Path .\file.txt -Algorithm MD5
Replace MD5
with SHA256
or another algorithm as needed. The output is the checksum value, which you can compare with a known good value to verify file integrity.