In the browser, I read the file using JS FileReader (). readAsBinaryString (). Using the CryptoJS library, I can MD5 hash data.
This works great, but I don't know how to handle large files. For instance. Just reading the 2GiB file causes the browser window to crash. I can cut the droplets from the file data and the hash, which is how I go, but does anyone stop checking the same hash without following the same steps as me?
Is there any way to get the md5 hash of a large file in this case? For example, how can you calculate the hash file of a md5 1TB file? Do I need to read the file as a stream?
The first time, I cut my teeth on this, and I'm not sure how to do it.
This is in the angular directive, therefore scope.
var reader = new FileReader();
reader.onload = function (loadEvent) {
scope.$apply(function () {
scope.files = changeEvent.target.files;
scope.fileread = loadEvent.target.result;
scope.md5Data = CryptoJS.MD5(scope.fileread).toString();
});
}
reader.readAsBinaryString((changeEvent.target.files[0]).slice(0, 10 * 1024 * 1024));
source
share