user80905: Concatenating and double SHA-256 hashing
"a751efbeabe73bdf9d08df5760104feff915d9d807d4c62178cdeb98d8c25f43" 
with itself
"a751efbeabe73bdf9d08df5760104feff915d9d807d4c62178cdeb98d8c25f43" 
should output
15eca0aa3e2cc2b9b4fbe0629f1dda87f329500fcdcd6ef546d163211266b3b3



import hashlib
      header_hex = "a751efbeabe73bdf9d08df5760104feff915d9d807d4c62178cdeb98d8c25f43a751efbeabe73bdf9d08df5760104feff915d9d807d4c62178cdeb98d8c25f43"
header_bin = header_hex.decode('hex')
hash = hashlib.sha256(hashlib.sha256(header_bin).digest()).digest()
hash.encode('hex_codec')
      '2b4a9fdb97e89e73c4647791e476090eaad04f43c93a3de21a95d2c4fc8e8e0c'



I'm getting the wrong answer :/?

user80905: You have to byte-swap the hex values BEFORE concatenating them. You also have to byte-swap the double hashed hex string!



import hashlib 
      header_hex = "435fc2d898ebcd7821c6d407d8d915f9ef4f106057df089ddf3be7abbeef51a7435fc2d898ebcd7821c6d407d8d915f9ef4f106057df089ddf3be7abbeef51a7" 
header_bin = header_hex.decode('hex') 
      hash = hashlib.sha256(hashlib.sha256(header_bin).digest()).digest() 
      hash.encode('hex_codec') 'b3b366122163d146f56ecdcd0f5029f387da1d9f62e0fbb4b9c22c3eaaa0ec15' >>> 
hash[::-1].encode('hex_codec') '15eca0aa3e2cc2b9b4fbe0629f1dda87f329500fcdcd6ef546d163211266b3b3' 




80905: <p>Concatenating and double SHA-256 hashing</p>

<p>"a751efbeabe73bdf9d08df5760104feff915d9d807d4c62178cdeb98d8c25f43" </p>

<p>with itself</p>

<p>"a751efbeabe73bdf9d08df5760104feff915d9d807d4c62178cdeb98d8c25f43" </p>

<p>should output
15eca0aa3e2cc2b9b4fbe0629f1dda87f329500fcdcd6ef546d163211266b3b3</p>

<blockquote>
  <blockquote>
    <blockquote>
      <p>import hashlib
      header_hex = "a751efbeabe73bdf9d08df5760104feff915d9d807d4c62178cdeb98d8c25f43a751efbeabe73bdf9d08df5760104feff915d9d807d4c62178cdeb98d8c25f43"</p>
      
      <p>header_bin = header_hex.decode('hex')</p>
      
      <p>hash = hashlib.sha256(hashlib.sha256(header_bin).digest()).digest()</p>
      
      <p>hash.encode('hex_codec')
      '2b4a9fdb97e89e73c4647791e476090eaad04f43c93a3de21a95d2c4fc8e8e0c'</p>
    </blockquote>
  </blockquote>
</blockquote>

<p>I'm getting the wrong answer :/?</p>
 80905: <p>You have to byte-swap the hex values BEFORE concatenating them. You also have to byte-swap the double hashed hex string!</p>

<blockquote>
  <blockquote>
    <blockquote>
      <p>import hashlib 
      header_hex = "435fc2d898ebcd7821c6d407d8d915f9ef4f106057df089ddf3be7abbeef51a7435fc2d898ebcd7821c6d407d8d915f9ef4f106057df089ddf3be7abbeef51a7" </p>
      
      <p>header_bin = header_hex.decode('hex') 
      hash = hashlib.sha256(hashlib.sha256(header_bin).digest()).digest() 
      hash.encode('hex_codec') 'b3b366122163d146f56ecdcd0f5029f387da1d9f62e0fbb4b9c22c3eaaa0ec15' >>> </p>
      
      <p>hash[::-1].encode('hex_codec') '15eca0aa3e2cc2b9b4fbe0629f1dda87f329500fcdcd6ef546d163211266b3b3' </p>
    </blockquote>
  </blockquote>
</blockquote>
