Author

Topic: [php] - OK I'm confused (Read 799 times)

full member
Activity: 168
Merit: 100
June 17, 2013, 02:55:43 PM
#5
It's because you are hashing the ASCII representation of the pubkey. You need to convert it to binary and hash that(i.e hex2bin). Trust me, happened to me too.

Thanks! That did it
sr. member
Activity: 420
Merit: 250
June 17, 2013, 09:52:30 AM
#4
It's because you are hashing the ASCII representation of the pubkey. You need to convert it to binary and hash that(i.e hex2bin). Trust me, happened to me too.
Wouldn't you want to do base_convert()?
legendary
Activity: 1176
Merit: 1280
May Bitcoin be touched by his Noodly Appendage
June 17, 2013, 07:56:38 AM
#3
That happens to a lot of people!

legendary
Activity: 1862
Merit: 1011
Reverse engineer from time to time
June 17, 2013, 07:49:49 AM
#2
It's because you are hashing the ASCII representation of the pubkey. You need to convert it to binary and hash that(i.e hex2bin). Trust me, happened to me too.
full member
Activity: 168
Merit: 100
June 17, 2013, 07:23:52 AM
#1
Hope this is the right place.

Code:
$pubKey="0450863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B23522CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6";
$stepTwo=hash('sha256',$pubKey);
die($stepTwo);
?>


gives me 32511e82d56dcea68eb774094e25bab0f8bdd9bc1eca1ceeda38c7a43aceddce

but https://en.bitcoin.it/wiki/Technical_background_of_Bitcoin_addresses

indicates it should be 600FFE422B4E00731A59557A5CCA46CC183944191006324A447BDB2D98D4B408

If it was just the lower case instead of upper I wouldn't care, but what's going on?
Is it because the php hash function is treating it as a string instead of a hex number?
Jump to: