SHA-256
Verify Your Files Contents
Checksums summarize a file into a single number. The algorithm calculates this number that makes it hard to find a file with a given checksum. This fact allows them to be used to verify that the file was not changed during transmission or over time. To verify your file, follow the steps below. If you don't enter the checksum into the text field, you have to compare them by hand. Files chosen on this site never leave your computer, all calculations happen locally.
1. Choose File:2. (Optional) Paste Expected SHA-256:
Verify Code.
const binStringOfFile = file => new Promise((resolve, reject) => { const reader = new FileReader(); reader.readAsBinaryString(file); reader.onload = () => resolve(reader.result); reader.onerror = error => reject(error); }); async function Main() { const file = document.querySelector('input[type=file]').files[0]; const fileString = await binStringOfFile(file); const sha = await digestMessage(fileString); document.getElementById("output-hash").innerHTML = "Calculated SHA-256:" + sha; const inputSHA = document.querySelector('input[type=text]').value; const outputEq = document.getElementById("output-equal"); if(inputSHA != "") { if(inputSHA == sha){ var str = "Both Sums are equal." str = str.concat(" You can expected that the content of the file was not changed."); outputEq.innerHTML = str; } else { var str = "Both Sums are different."; str = str.concat(" The content of the file was propably changed."); outputEq.innerHTML = str; } } } async function digestMessage(string) { // encode as (utf-8) Uint8Array const strUint8 = new TextEncoder().encode(string); // hash the message const hashBuffer = await crypto.subtle.digest('SHA-256', strUint8); // convert buffer to byte array const hashArray = Array.from(new Uint8Array(hashBuffer)); // convert bytes to hex string const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join(''); return hashHex; }