Last active
December 1, 2022 13:21
-
-
Save bilelz/c96fb0b1f62983d061910e8d310a5162 to your computer and use it in GitHub Desktop.
generate Checksum (Sha256) from a blob or a file (vanillajs)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function getChecksumSha256(blob: Blob): Promise<string> { | |
const uint8Array = new Uint8Array(await blob.arrayBuffer()); | |
const hashBuffer = await crypto.subtle.digest('SHA-256', uint8Array); | |
const hashArray = Array.from(new Uint8Array(hashBuffer)); | |
return hashArray.map((h) => h.toString(16).padStart(2, '0')).join(''); | |
// if you like, it, yan can buy me a coffee https://paypal.me/bilelz/1000000 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment