Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
165
rated 0 times [  167] [ 2]  / answers: 1 / hits: 8259  / 11 Years ago, tue, december 17, 2013, 12:00:00

I want to compare two Blobs to see if there are changes between them.


One way of doing this is by calculating the hash of the blobs and then comparing them, e.g.:


hash(firstBlob) === hash(secondBlob)

How can I calculate the hash of a Blob and check against another hash to see if they have changed?


More From » javascript

 Answers
17

I know this is kind of old but for someone looking for a better and newer solution please use the Crypto API and a SHA-256 or higher variant for the algorithm since MD5 has exploitable flaws.



var a = new FileReader();
a.readAsArrayBuffer(blob);
a.onloadend = function () {
let hashPromise = crypto.subtle.digest(SHA-256, a.result);// it outputs a promise
};

[#49477] Monday, December 16, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mckaylab

Total Points: 311
Total Questions: 120
Total Answers: 93

Location: Montenegro
Member since Thu, Jun 16, 2022
2 Years ago
;