Verify a File's SHA-256 Checksum in Your Browser
To verify a file, compute the SHA-256 digest of its original bytes and compare the full result with the publisher’s expected SHA-256 value. Use the same algorithm on both sides. A checksum copied from an unrelated version, or a checksum calculated from the filename instead of the file contents, will not perform the comparison you intended.
Andev’s hash generator hashes text entered into its text area. It does not currently accept a file upload. Use it to explore text digests, but do not paste a filename, a download URL, or a file’s Base64 representation into it and treat the result as the checksum of the original file. The browser example below reads an actual selected file.
Prepare the expected value first
Find the checksum associated with the exact file you downloaded. Check the version, platform, architecture, language, and archive format. A release can offer several similarly named downloads, each with a different checksum. Keep the filename beside the expected value until verification is complete.
Copy the checksum from a source you trust independently of the downloaded file. If someone can replace both a file and the checksum displayed next to it, making the two match does not establish that the file came from the intended publisher. Follow the publisher’s signature-verification instructions when authenticity is important and signatures are available.
Create a small verification record with four fields: download name, expected algorithm, expected checksum, and result. For shared work, add the date and the source page. This record is more useful than a note that simply says “checked,” because another person can repeat the same comparison against the same release.
Understand the input before hashing
A hash operates on bytes. The word report.pdf is a sequence of text characters; the contents of a PDF are a different byte sequence. Likewise, a ZIP archive and the files extracted from it are different inputs. If the publisher provides a checksum for the archive, verify the archive before extracting it.
The browser’s Web Crypto API provides crypto.subtle.digest() for SHA-256. A selected file can supply its bytes through arrayBuffer(). The digest result can be displayed as hexadecimal text. This API requires a secure context and reads the complete input into memory; it is not a streaming file-hashing interface. For large downloads, a local command-line checksum utility may be more practical. See the MDN digest reference for API requirements.
Do not decode a binary file as text before hashing it. A text decoder may replace bytes it cannot interpret, and a text editor may change line endings when saving. Those changes are enough to turn the comparison into a test of a different file.
A small browser example
The following example is for developers who can serve a simple page from localhost or HTTPS. It includes a file picker, a field for the expected digest, and an explicit result message. It does not send the selected file to a server. Check the page code and your hosting environment before using any browser workflow for private material.
<label>File <input id="file" type="file"></label>
<label>Expected SHA-256 <input id="expected" type="text"></label>
<button id="verify" type="button">Verify</button>
<pre id="result" aria-live="polite"></pre>
<script type="module">
const fileInput = document.querySelector('#file');
const expectedInput = document.querySelector('#expected');
const button = document.querySelector('#verify');
const result = document.querySelector('#result');
async function sha256(file) {
const digest = await crypto.subtle.digest('SHA-256', await file.arrayBuffer());
return Array.from(new Uint8Array(digest), byte =>
byte.toString(16).padStart(2, '0')
).join('');
}
button.addEventListener('click', async () => {
const file = fileInput.files[0];
const expected = expectedInput.value.trim().toLowerCase();
if (!file || !/^[0-9a-f]{64}$/.test(expected)) {
result.textContent = 'Select a file and enter a 64-digit hexadecimal SHA-256 value.';
return;
}
button.disabled = true;
result.textContent = 'Calculating…';
try {
const actual = await sha256(file);
result.textContent = `${file.name}\n${actual}\n${actual === expected ? 'MATCH' : 'MISMATCH'}`;
} catch {
result.textContent = 'Could not calculate the checksum. Check browser support and available memory.';
} finally {
button.disabled = false;
}
});
</script> Choose the file, paste only the hexadecimal checksum, and click Verify. If the publisher’s checksum file includes an algorithm label or filename on the same line, do not include those extra fields. Uppercase and lowercase hexadecimal letters represent the same value; this example normalizes their case and trims surrounding whitespace.
The page reports a result for the file and expected value captured when you click the button. If you change either field during a calculation, click Verify again for the new pair. For a production tool, you could also disable the inputs while work is in progress and show a progress explanation for large files.
Work through a mismatch systematically
First confirm the algorithm. A SHA-512 checksum is not interchangeable with SHA-256 even when both values appear under a heading such as “checksums.” Next compare the filename and release details against the expected entry. A download for another operating system is a common source of confusion when release pages contain many adjacent links.
Then check whether the file finished downloading. A partial transfer can leave a file with a plausible name but incomplete content. Download again from the official source and repeat the comparison. Avoid opening or executing an unexpected file merely to investigate why its checksum differs.
Finally, consider changes made after downloading. Extracting an archive, editing a configuration file, normalizing text line endings, or re-saving a document creates a different input. Verify the original downloaded artifact when that is what the published checksum describes. If you intentionally changed it, calculate a new digest for your own records without presenting it as the publisher’s original value.
Keep hashes, encodings, and identifiers separate
| Operation | Question it answers | Appropriate tool |
|---|---|---|
| Hash text | What digest corresponds to these encoded characters? | Hash generator |
| Encode or decode Base64 | How can these data be represented or recovered as encoded text? | Base64 tool |
| Generate an identifier | What label can I assign to this record or job? | UUID generator |
| Verify a file checksum | Does this file produce the expected digest? | A file-aware hashing workflow |
For a practical handoff, assign a job identifier to the verification record and store the checksum as a separate field. The identifier helps people refer to the job; it does not verify the attachment. Similarly, an encoded representation can be useful for transport, but hashing that representation answers a different question from hashing the original bytes.
Frequently asked questions
Can I check a file by pasting its contents into the text tool?
For exact file verification, use a workflow that reads the original bytes. Copying text can lose a byte-order marker, alter line endings, or omit a final newline. The displayed text may look identical while the file’s byte sequence is different.
Does a match mean the download is safe to run?
A match means the computed digest agrees with the expected value you supplied. It is not a malware scan and does not establish who provided that value. Keep source verification and software trust decisions separate from the mechanical checksum comparison.
Can I compare only the beginning of the checksum?
Compare the complete value. A quick glance at the first few characters is an incomplete check and gives you less information than the full comparison already available. Copy the entire expected digest and let the tool compare it exactly.
What should I retain after verification?
Save the expected value, the computed value, the algorithm, and the precise release name. If the file is later replaced or edited, repeat verification. A past match describes the file you checked at that moment, not every future file with the same name.