title: HMAC-SHA256 Algorithm for signature calculation
body: <p>I am trying to create a signature using the HMAC-SHA256 algorithm and this is my code.
  I am using US ASCII encoding.</p>
  <pre><code>final Charset asciiCs = Charset.forName(&quot;US-ASCII&quot;);
  final Mac sha256_HMAC = Mac.getInstance(&quot;HmacSHA256&quot;);
  final SecretKeySpec secret_key = new javax.crypto.spec.SecretKeySpec(asciiCs.encode(&quot;key&quot;).array(), &quot;HmacSHA256&quot;);
  sha256_HMAC.init(secret_key);
  final byte[] mac_data = sha256_HMAC.doFinal(asciiCs.encode(&quot;The quick brown fox jumps over the lazy dog&quot;).array());
  String result = &quot;&quot;;
  for (final byte element : mac_data)
  {
      result += Integer.toString((element &amp; 0xff) + 0x100, 16).substring(1);
  }
  System.out.println(&quot;Result:[&quot; + result + &quot;]&quot;);
  </code></pre>
  <p>The result that I am getting from the above code is:</p>
  <pre><code>f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8
  </code></pre>
  <p>This is same as to that of shown in the wiki</p>
  <pre><code>HMAC_SHA256(&quot;key&quot;, &quot;The quick brown fox jumps over the lazy dog&quot;) = 0x f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8
  </code></pre>
  <p><em>except</em> for the <code>0x</code>.</p>
  <p>I am looking for ideas/comments if I am doing everything right or may be I can improve my code.</p>