Title: problem with sha256 hashing of block header Post by: instant_trader on May 27, 2017, 08:36:00 AM Hi
i have problem (or misunderstanding with sha256 hashing of block header) i use this code Code: import hashlib, struct and it is here online https://repl.it/Pkp (https://repl.it/Pkp) so as you can see it works perfectly and solve that block but when i trace it line by line (when it reaches correct nonce that is 856192328 0x33087548) first it make this block header Code: 0200000017975b97c18ed1f7e255adf297599b55330edab87803c81701000000000000008a97295a2747b4f1a0b3948df3990344c0e19fa6b2b92b3a19c8e6badc141787358b0553535f011948750833 and then hash it with sha256 that output is Code: e6d91555891f9c0d0313625ff8cbfecc917063ade047c2eaf73e7a28862b127c and then again hash Code: 0000000000000000e067a478024addfecdc93628978aa52d91fabd4292982a50 but when i hash the header block with some sha256 online hasher like http://www.xorbin.com/tools/sha256-hash-calculator (http://www.xorbin.com/tools/sha256-hash-calculator) the output is Code: 1a4ad61b28b74f4ce89b589ed862ac204019c3297b6431529d141f8b82fb56ea Code: a071333e34ecdca0c9f7d7f7d42192ebb6cc3e3e47a4b20a02108246a5bd8e1c and you can see it is incorrect! what is wrong whit it? Title: Re: problem with sha256 hashing of block header Post by: achow101 on May 27, 2017, 10:20:02 AM When you are hashing with the script, you are hashing the bytes. When you use a different tool for hashing, you are hashing the string with the hexadecimal representation of the bytes. The bytes are what need to be hashed, the string is only to make it human readable.
Title: Re: problem with sha256 hashing of block header Post by: instant_trader on May 27, 2017, 10:33:00 AM When you are hashing with the script, you are hashing the bytes. When you use a different tool for hashing, you are hashing the string with the hexadecimal representation of the bytes. The bytes are what need to be hashed, the string is only to make it human readable. thanks,I checked it with byte[] and it works fine. :) |