I wish to calculate a file's checksum locally with JS and have been searching for examples of how to accomplish this using the Streams Api and pipeTo, but have only found examples with Node.js which I am not familiar with. What I'm looking for is something like this:
var stream = file.stream();
var hash = CryptoJS.algo.SHA1.create();
await stream.pipeTo(hash);
console.log(hash);
This code does not work since CryptoJS doesn't seem to create WriteableStream. Can I wrap what CryptoJS creates in some kind of shim or sink? Other suggestions?
I could read and append buffers incrementally of course, but the code becomes a bit messy so I was hoping I could leverage pipeTo to avoid complicating the code.