Bitcoin Forum

Other => Beginners & Help => Topic started by: b129 on April 29, 2013, 09:49:24 PM



Title: Double hashing question
Post by: b129 on April 29, 2013, 09:49:24 PM
Am trying to verify some code I have written:

I am using a sample message "hello" and run a single sha256 hash and get the correct result, but try to hash the result and don't get the same result for the 2nd hash....

I am referencing the following page:
https://en.bitcoin.it/wiki/Protocol_specification

My single sha256 hash is verified, and agrees with the following:
http://www.xorbin.com/tools/sha256-hash-calculator

Is there a step I am missing for calculating the second hash?

Sha256("hello") = "2cf24dba...."
Sha256("2cf24dba....") <> "9595c9d..."


Title: Re: Double hashing question
Post by: DannyHamilton on April 30, 2013, 01:14:47 AM
Am trying to verify some code I have written:

I am using a sample message "hello" and run a single sha256 hash and get the correct result, but try to hash the result and don't get the same result for the 2nd hash....

I am referencing the following page:
https://en.bitcoin.it/wiki/Protocol_specification

My single sha256 hash is verified, and agrees with the following:
http://www.xorbin.com/tools/sha256-hash-calculator

Is there a step I am missing for calculating the second hash?

Sha256("hello") = "2cf24dba...."
Sha256("2cf24dba....") <> "9595c9d..."

I suspect you are treating the first hash as a string of alphanumeric characters instead of a block of hexcode bytes.


Title: Re: Double hashing question
Post by: b129 on April 30, 2013, 01:28:25 AM
Good point - that should be the answer - sometimes easiest solution is right in front of you just takes someone else to notice.


Title: Re: Double hashing question
Post by: b129 on April 30, 2013, 07:48:01 AM
Yep worked that's all it was thanks


Title: Re: Double hashing question
Post by: candelone on April 30, 2013, 07:54:14 AM
very goog work