samedi 23 juillet 2016

How to calculate the checksum of a file using Node crypto and get same results as manual calculation

I am trying to get the checksum/hash from a file upload on my webpage.

I am currently able to upload the file via my browser then calculate the hash using the node.js crypto library. I first convert the blob to a data Url.

export function calculateHash(dataUrl, type){

  const sha1sum = crypto.createHash('sha1').update(dataUrl).digest("hex");
  console.log('Hash sum is ' + sha1sum);

}

Result: 66b8bdd2d1d49f708722c15b26409bc072096697

When i calculate the hash manually from the windows command prompt using the following command..

fciv.exe 1_1.wav -sha1

Result: b06071b13a1b50cd2976ed7bb4180f6963e8db8e

I would like to get the same checksum result from the data url in my browser as doing the manual check from the command prompt.

Is this possible?

Aucun commentaire:

Enregistrer un commentaire