title: CryptoJS (HMAC Sha256) giving incorrect output?
body: <p>Let me start by saying I'm no expert in cryptography algorithms...</p>
  
  <p>I am trying to build a method which formats an HTTP header for Windows Azure - and this header requires part of its message to be encrypted via HMAC with SHA256 (and then also base64 encoded).</p>
  
  <p>I chose to use <a href="https://code.google.com/p/crypto-js/" rel="nofollow">CryptoJS</a> because it's got an active user community.</p>
  
  <p>First, my code:</p>
  
  <pre><code>_encodeAuthHeader : function (url, params, date) {
      //http://msdn.microsoft.com/en-us/library/windowsazure/dd179428
      var canonicalizedResource = '/' + this.getAccountName() + url;
  
      /*
       StringToSign = Date + "\n" + CanonicalizedResource
       */
      var stringToSign = date + '\n' + canonicalizedResource;
      console.log('stringToSign &gt;&gt; ' + stringToSign)
  
      var encodedBits = CryptoJS.HmacSHA256(stringToSign, this.getAccessKey());
      console.log('encodedBits &gt;&gt; ' + encodedBits);
  
      var base64Bits = CryptoJS.enc.Base64.stringify(encodedBits);
      console.log('base64Bits &gt;&gt; ' + base64Bits);
  
      var signature = 'SharedKeyLite ' + this.getAccountName() + ':' + base64Bits;
      console.log('signature &gt;&gt; ' + signature);
  
      return signature;
  },
  </code></pre>
  
  <p>The method successfully returns a "signature" with the appropriate piece encrypted/encoded. However, Azure complains that it's not formatted correctly.</p>
  
  <p>Some example output:</p>
  
  <pre><code>stringToSign &gt;&gt; Mon, 29 Jul 2013 16:04:20 GMT\n/senchaazurestorage/Tables
  
  encodedBits &gt;&gt; 6723ace2ec7b0348e1270ccbaab802bfa5c1bbdddd108aece88c739051a8a767
  
  base64Bits &gt;&gt; ZyOs4ux7A0jhJwzLqrgCv6XBu93dEIrs6IxzkFGop2c=
  
  signature &gt;&gt; SharedKeyLite senchaazurestorage:ZyOs4ux7A0jhJwzLqrgCv6XBu93dEIrs6IxzkFGop2c=
  </code></pre>
  
  <p>Doing some debugging, I am noticing that CryptoJS is not returning the same value (HMAC with SHA256) as alternative implementations. For example, the string "<em>Mon, 29 Jul 2013 16:04:20 GMT\n/senchaazurestorage/Tables</em>" appears as:</p>
  
  <ul>
  <li>"<em>6723ace2ec7b0348e1270ccbaab802bfa5c1bbdddd108aece88c739051a8a767</em>" via CryptoJS</li>
  <li>"<em>faa89f45ef029c63d04b8522d07c54024ae711924822c402b2d387d05398fc9f</em>" via PHP hash_hmac('sha256', ... )</li>
  </ul>
  
  <p>Digging even deeper, I'm seeing that most HMAC/SHA265 algorithms return data which matches the output from PHP... am I missing something in CryptoJS? Or is there a legitimate difference?</p>