lundi 13 juin 2016

Sha256 returning incorrect hash values?


I'm trying to hash a bitcoin private key to get the checksum, and two different libraries in python (hashlib + pycrypto) are returning the same incorrect result (after just 1 hash).

In linux terminal, I get the correct hash result with the line:

echo -n 8018ac3e7343f016890c510e93f935261169d9e3f565436429830faf0934f4f8e4 | xxd -r -p | sha256sum -b
result: cd358f378809b3043ded3782d849fbad70f92a2dadefafd985d9aef443752e57

However, hashlib, pycrypto, and an online SHA2 hash tool return the value:

5d6dce0f36a50abe51ee435ac11dac05f7879c1cd1ca5bc7aae706e5a3776d4a

I'm not sure why they are returning different values.

Here are two WIF-keys generated from them, the top one using the command line function, the second using python; the second one is invalid (not accepted by wallet softwares).

5J19pGYtJzuS7VoAQjxDjUGgWXSNqj18GWSWvFVqJzQqGtxZf2V
5J19pGYtJzuS7VoAQjxDjUGgWXSNqj18GWSWvFVqJzQqGvDc8hm

Aucun commentaire:

Enregistrer un commentaire