title: Build hmac sha256 hashing algorithm in node.js
body: <p>I am using <a href="https://docs.boldapps.net/subscriptions/integration/#securing-webhooks" rel="nofollow noreferrer">Bold Commerce Webhooks</a> to subscribe to subscription events in my store. They give documentation about how their request signatures are generated in PHP:</p>
  <pre><code>$now = time(); // current unix timestamp
  $json = json_encode($payload, JSON_FORCE_OBJECT);
  $signature = hash_hmac('sha256', $now.'.'.$json, $signingKey);
  </code></pre>
  <p>I'm trying to recreate the hash on my side in node.js. From my research I've figured out the following so far, which I believe is pretty close, but doesn't match yet:</p>
  <pre><code>const hash = request.header(&quot;X-Bold-Signature&quot;)!;
  
  const SECRET = &quot;my-secret-api-key&quot;;
  const body = request.body;
  const time = request.header(&quot;timestamp&quot;)!;
  
  const mySignature = crypto.createHmac('sha256', SECRET).update(time + '.' + body).digest(&quot;hex&quot;);
  
  if (mySignature !== request.header(&quot;X-Bold-Signature&quot;)!) {
      //...
  }
  </code></pre>
  <p>I've also tried using <code>JSON.stringify(body)</code> which changes the hash but still doesn't match.</p>