Last active
August 29, 2015 13:58
-
-
Save qikcoin/10006122 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from: | |
https://en.bitcoin.it/wiki/Block_hashing_algorithm | |
this python code will calculate the hash of the block with the smallest hash as of June 2011, Block 125552. The header is built from the six fields described above, concatenated together as little-endian values in hex notation: | |
>>> import hashlib | |
>>> header_hex = ("01000000" + | |
"81cd02ab7e569e8bcd9317e2fe99f2de44d49ab2b8851ba4a308000000000000" + | |
"e320b6c2fffc8d750423db8b1eb942ae710e951ed797f7affc8892b0f1fc122b" + | |
"c7f5d74d" + | |
"f2b9441a" + | |
"42a14695") | |
>>> header_bin = header_hex.decode('hex') | |
>>> hash = hashlib.sha256(hashlib.sha256(header_bin).digest()).digest() | |
>>> hash.encode('hex_codec') | |
'1dbd981fe6985776b644b173a4d0385ddc1aa2a829688d1e0000000000000000' | |
>>> hash[::-1].encode('hex_codec') | |
'00000000000000001e8d6829a8a21adc5d38d0a473b144b6765798e61f98bd1d' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment