title: Issue calculating MD5 hash of Amazon Marketplace feed
body: <p>I’m trying to submit a <code>SubmitFeed</code> request to Amazon Marketplace, but when I submit the request I get the following error:</p>
  
  <blockquote>
    <p>the Content-MD5 HTTP header you passed for your feed did not match the Content-MD5 we calculated for your feed</p>
  </blockquote>
  
  <p>So I tested the request on the <a href="https://mws.amazonservices.co.uk/scratchpad/index.html" rel="nofollow">Amazon Marketplace Scratchpad</a>. I add my XML to the body, and the headers, and it generates the following MD5 hash:</p>
  
  <blockquote>
    <p>1db3b177e743dc8c0df4dc9eb5c1cbcf</p>
  </blockquote>
  
  <p>But there’s also a <code>Content-MD5 (Base64)</code> header, with this value:</p>
  
  <blockquote>
    <p>HbOxd+dD3IwN9NyetcHLzw==</p>
  </blockquote>
  
  <p>And it appears to be <em>that</em> value that’s actually sent to Amazon 
  MWS as the <code>Content-MD5</code> HTTP header, not the raw MD5 hash.</p>
  
  <p>I’ve checked my PHP script and it’s generating the raw MD5 hash correctly, as when I wrap my XML string in the <code>md5</code> function (<code>md5($xml)</code>) I get the same raw MD5 hash that Amazon generates. But if I then wrap <em>that</em> in the <code>base64_encode</code> function, I get a totally different value as to what Amazon lists for the Content-MD5 (Base64) value.</p>
  
  <p>So far, I’ve tried wrapping the following in the <code>base64_encode</code> function:</p>
  
  <ul>
  <li>The raw XML string</li>
  <li>The MD5 hash of the raw XML string</li>
  </ul>
  
  <p>But none yield the same value as Amazon’s Content-MD5 (Base64) value.</p>
  
  <p>So what exactly <em>is</em> Amazon Base64-encoding to get that value? I’ve tried decoding the value, but just got a load of random characters that appears to be an encoding issue, so I can’t see the raw string that Amazon’s encoding to point me in the right direction.</p>
  
  <p>Any guidance on this would be appreciated.</p>