title: Working with bytes in Python using SHA-256
body: <p>So I want to use SHA-256 for a specific problem: Calculate digest from a bytearray, then concatenate the resulting digest to another block of bytes ( a 1024 byte block for this problem ) and calculate the digest for the concatenated values.</p>
  
  <p>For example:</p>
  
  <p>Here are my two byte blocks:</p>
  
  <pre><code>from hashlib import sha256
  rawhex4 = b'\x44'*773
  rawhex3 = b'\x33'*1024
  
  h = sha256()
  h.update(rawhex4)
  aux = h.digest()
  </code></pre>
  
  <p>This hexdigest is: d8f8a9eadd284c4dbd94af448fefb24940251e75ca2943df31f7cfbb6a4f97ed</p>
  
  <p>then I want to concatenate this 32 byte digest to my next block and hash it but I am not getting the correct answer. I do the following:</p>
  
  <pre><code>h.update(rawhex3 + aux)
  </code></pre>
  
  <p>I know for fact that hashing rawhex3 + hash(rawhex4) will give me this digest:</p>
  
  <p>26949e3320c315f179e2dfc95a4158dcf9a9f6ebf3dfc69252cd83ad274eeafa</p>
  
  <p>What could I be missing? I am pretty new to Python</p>