title: Testing HmacSHA256 signature
body: <p>I'm testing my Hmac with test vectors from <a href="https://www.rfc-editor.org/rfc/rfc4231" rel="nofollow noreferrer">https://www.rfc-editor.org/rfc/rfc4231</a></p>
  <p>But on test case 3 &quot;Test with a combined length of key and data that is larger than 64 bytes (= block-size of SHA-224 and SHA-256).&quot; I get a different digest than the correct one.</p>
  <pre><code>byte[] key = hexify(&quot;aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&quot;);
  byte[] data = hexify(&quot;dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd&quot;);
  byte[] correct = hexify(&quot;773ea91e36800e46854db8ebd09181a72959098b3ef8c122d9635514ced565fe&quot;);
  
  // Create digest
  SecretKey macKey = new SecretKeySpec(key, &quot;HmacSHA256&quot;);
  Mac mac = Mac.getInstance(&quot;HmacSHA256&quot;);
  mac.init(macKey);
  byte[] digest = mac.doFinal(data);
  </code></pre>
  <p>Any idea why they become different? What did I miss? I'm very new to this.</p>
  <pre><code>// Hex encoded
  a5418172bb54bf71f3ec28d1c9f34c48da17007eac4d0ca9e2f8ab54b91603e8
  773ea91e36800e46854db8ebd09181a72959098b3ef8c122d9635514ced565fe
  </code></pre>