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,040 points
26 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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
• 27,620 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 2, 2018 in Blockchain by Priyaj
• 56,120 points
45 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 ariaholic
• 7,320 points
21 views
0 votes
1 answer

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

yes all are over TCP/IP connections secured by TLS encryption in hashgraph architecture-hashgraph, ...READ MORE

answered Aug 6, 2018 in Blockchain by ariaholic
• 7,320 points
42 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
62 views
0 votes
1 answer
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
• 27,620 points
40 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
• 27,620 points
22 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.