3

I am new to bitcoin. When I use this online 'Script Execution' site, to calculate the SHA256 hash of 1, I get 4bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459a but using any other online calculator you get a different result 6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b So probably OP_SHA256 is not what I think, or something happens to input after 1 is pushed into stack.

12

Your conflict is caused because you are hashing different values in the two situations.

>>> import hashlib
>>> hashlib.sha256("1").hexdigest()
'6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b'

Your online tools are showing the hash of the string "1".

>>> hashlib.sha256("\x01").hexdigest()
'4bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459a'

Bitcoin script stack elements are bytes, for OP_1 this is 01.

  • @AdrianCousot I suggest marking it as the answer. – Gene Oct 18 '15 at 2:33
  • @PandaLion98 New users have to wait 8 hours to accept an answer. So he could do it now, but not then. – Michael Hampton Oct 18 '15 at 3:42
  • @MichaelHampton I'm aware of that :) – Gene Oct 18 '15 at 3:51
  • 2
    Many thanks , I don't have enough rep to vote you – Adrian Cousot Oct 18 '15 at 6:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.