title: Calculating a SHA hash with a string + secret key in python
body: <p>Amazon Product API now requires a signature with every request which I'm trying to generate ushing Python.</p>
  
  <p>The step I get hung up on is this one:</p>
  
  <p>"Calculate an RFC 2104-compliant HMAC with the SHA256 hash algorithm using the string above with our "dummy" Secret Access Key: 1234567890. For more information about this step, see documentation and code samples for your programming language." </p>
  
  <p>Given a string and a secret key (in this case 1234567890) how do I calculate this hash using Python?</p>
  
  <p>----------- UPDATE -------------</p>
  
  <p>The first solution using HMAC.new looks correct however I'm getting a different result than they are.</p>
  
  <p><a href="http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/index.html?rest-signature.html" rel="noreferrer">http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/index.html?rest-signature.html</a></p>
  
  <p>According to Amazon's example when you hash the secret key 1234567890 and the following string</p>
  
  <pre><code>GET
  webservices.amazon.com
  /onca/xml
  AWSAccessKeyId=00000000000000000000&amp;ItemId=0679722769&amp;Operation=I
  temLookup&amp;ResponseGroup=ItemAttributes%2COffers%2CImages%2CReview
  s&amp;Service=AWSECommerceService&amp;Timestamp=2009-01-01T12%3A00%3A00Z&amp;
  Version=2009-01-06
  </code></pre>
  
  <p>You should get the following signature: <code>'Nace+U3Az4OhN7tISqgs1vdLBHBEijWcBeCqL5xN9xg='</code></p>
  
  <p>I am getting this:  <code>'411a59403c9f58b4a434c9c6a14ef6e363acc1d1bb2c6faf9adc30e20898c83b'</code></p>