crypto.subtle.digest('SHA-256', buffer) is the first thing most of us reach for when we need a file hash in JavaScript. It works, until someone drops a 5 GB disk image on the page. digest() has no streaming API: it wants the whole file in one ArrayBuffer , so memory grows with the file and the tab eventually dies.
We hit this while building a checksum verifier that compares downloads against a published SHA-256, MD5 or a whole SHA256SUMS list, without uploading anything. Here is the approach we ended up with and the details that took longer than expected.
Read the file in slices, feed a streaming hasher
A File is a Blob , and Blob.slice() is cheap: it returns a view, and nothing is read until you ask for the bytes.…