Learn how to use file hashes to make sure your downloads are safe and not broken.
// Client-side SHA-256 calculation using Web Crypto API
async function computeSHA256(arrayBuffer: ArrayBuffer): Promise<string> {
const hashBuffer = await crypto.subtle.digest('SHA-256', arrayBuffer);
const hashArray = Array.from(new Uint8Array(hashBuffer));
return hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
}