Bitcoin Forum
June 17, 2024, 04:31:24 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: [php] - OK I'm confused  (Read 773 times)
AliceWonder (OP)
Full Member
***
Offline Offline

Activity: 168
Merit: 100



View Profile
June 17, 2013, 12:23:52 PM
 #1

Hope this is the right place.

Code:
<?php
$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?

QuarkCoin - what I believe bitcoin was intended to be. On reddit: http://www.reddit.com/r/QuarkCoin/
Remember remember the 5th of November
Legendary
*
Offline Offline

Activity: 1862
Merit: 1011

Reverse engineer from time to time


View Profile
June 17, 2013, 12:49:49 PM
 #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.

BTC:1AiCRMxgf1ptVQwx6hDuKMu4f7F27QmJC2
jackjack
Legendary
*
Offline Offline

Activity: 1176
Merit: 1255


May Bitcoin be touched by his Noodly Appendage


View Profile
June 17, 2013, 12:56:38 PM
 #3

That happens to a lot of people!


Own address: 19QkqAza7BHFTuoz9N8UQkryP4E9jHo4N3 - Pywallet support: 1AQDfx22pKGgXnUZFL1e4UKos3QqvRzNh5 - Bitcointalk++ script support: 1Pxeccscj1ygseTdSV1qUqQCanp2B2NMM2
Pywallet: instructions. Encrypted wallet support, export/import keys/addresses, backup wallets, export/import CSV data from/into wallet, merge wallets, delete/import addresses and transactions, recover altcoins sent to bitcoin addresses, sign/verify messages and files with Bitcoin addresses, recover deleted wallets, etc.
Jaxkr
Sr. Member
****
Offline Offline

Activity: 420
Merit: 250


View Profile
June 17, 2013, 02:52:30 PM
 #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()?
AliceWonder (OP)
Full Member
***
Offline Offline

Activity: 168
Merit: 100



View Profile
June 17, 2013, 07: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

QuarkCoin - what I believe bitcoin was intended to be. On reddit: http://www.reddit.com/r/QuarkCoin/
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!