SHA256 does not give expected result

0 votes

I am following the tutorial on this site: https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses#How_to_create_Bitcoin_Address

In part 2 it shows that the SHA256 yields a result different than what I get when I am running my python code:

the string is: 0450863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B23522CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6

While the tutorial SHA256 comes to: 600FFE422B4E00731A59557A5CCA46CC183944191006324A447BDB2D98D4B408

My short python shows:

sha_result = sha256(bitconin_addresss).hexdigest().upper()

print sha_result


32511E82D56DCEA68EB774094E25BAB0F8BDD9BC1ECA1CEEDA38C7A43ACEDDCE

What am I doing wrong?

Aug 24, 2018 in Blockchain by slayer
• 29,350 points
941 views

1 answer to this question.

0 votes
You're hashing the string when you're supposed to be hashing the bytes represented by that string.

>>> hashlib.sha256('0450863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B23522CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6'.decode('hex')).hexdigest().upper()

'600FFE422B4E00731A59557A5CCA46CC183944191006324A447BDB2D98D4B408'
answered Aug 24, 2018 by digger
• 26,740 points
How did you know that it was a string and not the bytes? I am asking because I couldn’t tell the difference.
It's a string of hexadecimal digits, so I figure it had to represent a bytestring.

Related Questions In Blockchain

0 votes
2 answers

Why does not India consider Bitcoin as a legal tender?

to be specific there are few logical ...READ MORE

answered Jul 3, 2018 in Blockchain by Priyaj
• 58,090 points
629 views
0 votes
1 answer
0 votes
1 answer

Is it possible to claim Bitcoin Cash from an exchange that does not support it?

You can't claim BCH without knowing private ...READ MORE

answered Jul 17, 2018 in Blockchain by aryya
• 7,450 points
557 views
+1 vote
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured ...READ MORE

answered Aug 6, 2018 in Blockchain by aryya
• 7,450 points
1,171 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,732 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,259 views
0 votes
1 answer

Getting wrong result from SHA256 than what is expected

It's just an encoding issue - don't ...READ MORE

answered Sep 6, 2018 in Blockchain by digger
• 26,740 points
1,469 views
0 votes
1 answer

Not getting correct result after SHA256

You have to: Hash with SHA-256 the public key: 0450863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B23522CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6 Hash with RIPEMD-160 the ...READ MORE

answered Sep 11, 2018 in Blockchain by digger
• 26,740 points
727 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP