Calculate MD5 hash blob

How can I calculate the MD5 Blob hash and check for a different hash to see if they have changed?

EDIT: I am currently using CryptoJS

+4
source share
1 answer

You can use the FileReaderAPI to get the blob contents for comparison. If you need to use CryptoJS for this, you can use readAsBinaryString:

var a = new FileReader();
a.readAsBinaryString(blob);
a.onloadend = function () {
  console.log(CryptoJS.MD5(CryptoJS.enc.Latin1.parse(a.result)));
};

Note that it is readAsBinaryStringdeprecated, so if you can use another library like SparkMD5 , you can use the array buffer instead:

var a = new FileReader();
a.readAsArrayBuffer(blob);
a.onloadend = function () {
  console.log(SparkMD5.ArrayBuffer.hash(a.result));
};
+4
source

All Articles