Skip to main content
1 of 2
Will-In-China
  • 468
  • 2
  • 4
  • 11

Is this how I should calculate a Double SHA256

So I have a function called sha256 which will take a string and return the SHA-256 hash.

var First = sha256('myfirstSHA');

And the output is

9b2b95b24dd9149480ebda21aafe3f1a3c0370798ceec3c4d09c6a16adfe01c8

All feels good here, but if I want a double SHA-256 how should I go abut calculating it? Can I just use the same function as above twice? like this...

var Second = sha256(sha256('myfirstSHA'));

What should the value of Second be?

I get the feeling I may need to get the value of the first hash and convert it to something before putting it back through the function a second time??

Any advice is most welcome!

Will-In-China
  • 468
  • 2
  • 4
  • 11