I am trying to get the same result I obtain at http://jssha.sourceforge.net/
where
I have the word ‘testing’ in question:
var word = 'testing';
var hex = toHex(word); // '740065007300740069006e006700';
on jssha when selecting input type as HEX with the value of the hex variable and SHA-512 I get the following result:
6e42b2c2a6351036b78384212774135d99d849da3066264983e495b5f74dc922e3d361b8ea9c8527169757233ed0bd4e56b2c42aab0a21bbcca67219dc53b472
although I can’t achieve the same result with nodejs crypto module.
require('crypto').createHash('sha512').update(hex).digest('hex')
outputs:
9ad6d9053c6c420fe61ec2fffd094e3a325bc71708e18232fd764a5eb30315e38464e620ef0b55b92fbf6c809838652a72d9412b0398b28d61ca432962451de2
So I am wondering how can I get the same result as jssha using crypto module?
Thanks
“testing” in hex is 74657374696e67 if you use utf8 which is pretty much standard. What your toHex method returns assumes utf16.
For that hash, the website says:
Do this in node.js to hash a hex string:
Node gives you the same hash. Oh, and this also gives you the same hash: