Taras Kravets Taras Kravets - 1 month ago 8
Javascript Question

How to generate MD5 file hash on javascript?

How to write

functionForGenerateMD5hash
for this code? I already have
fileVideo
and I need to send md5 hash of this file to server by clicking button.

$("#someButton").click(function() {
var fr = new FileReader();
fr.onload = function(e) {
string md5 = functionForGenerateMD5hash(e.target.result);
// send md5 here
};
fr.readAsArrayBuffer(fileVideo);

Answer

There are functions to generate MD5 hashes are located here:

http://www.myersdaily.org/joseph/javascript/md5-text.html

http://pajhome.org.uk/crypt/md5/md5.html

However I would recommend using a more secure hash such as SHA256