Reputation: 493
const crypto = require('crypto');
hm = crypto.createHmac("sha256","Some String");
console.log(hm.digest("base64"));
Running this gives me:
Nd6Q8epsIBG+c/jN6TdnfRNbFWCcB7bI0DYkfyDqf+8=
But calculating the sha256 at https://approsto.com/sha-generator/ gives me:
fw/WRlO6C7Glec7Str83XpFsxgZiEJ7gwLJPCnUMOmw
Why is there a difference?
Upvotes: 1
Views: 1637
Reputation: 361605
const crypto = require('crypto');
hash = crypto.createHash("sha256");
hash.update("Some String");
console.log(hash.digest("base64"));
Result:
fw/WRlO6C7Glec7Str83XpFsxgZiEJ7gwLJPCnUMOmw=
See also:
Upvotes: 4