title: How to implement hmacSHA256 with Javascipt using CryptoJS
body: <p>We can calculate a hmac with <code>CryptoJS.HmacSHA256(message, key)</code></p>
  <p>But I want to implement it with the formula <code>Sha256( concat ( key xor opad, Sha256( concat( key xor ipad, message ) )</code></p>
  <p>I did the following</p>
  <pre class="lang-js prettyprint-override"><code>const key   = &quot;e9058ab198f6908f702111b0c0fb5b36f99d00554521886c40e2891b349dc7a1&quot;;
  const ipad  = &quot;3636363636363636363636363636363636363636363636363636363636363636&quot;;
  const opad  = &quot;5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c&quot;;
  const mess  = &quot;2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824&quot;;
  
  const alpha = &quot;b559d6edc4aaccd32c7d4dec9ca7076aa5c15c09197dd4301cbed54768c19bfd&quot;; // key xor opad
  const beta  = &quot;df33bc87aec0a6b946172786f6cd6d00cfab36637317be5a76d4bf2d02abf197&quot;; // key xor ipad
  
  const hmac  = CryptoJS.SHA256( alpha + String ( CryptoJS.SHA256( ( beta + mess ) ) ) ) ;
  </code></pre>
  <p>But it doesnt work, any help ?</p>
  <p>for example, with the code below I found<br>
  <code>hmac = &quot;594b7b8b1dea8dd016c1702c5b2d8b75ba20d744423b08e8897f02454000abad&quot;</code></p>
  <p>but the real one is : <code>&quot;fc7e0b4417a84790035480f97f9a792d8328a497039ae483b4b85197c008669e&quot;</code>
  and it's calculated with <code>CryptoJS.HmacSHA256(CryptoJS.enc.Hex.parse(mess), key))</code></p>