title: OpenSSL HMAC-SHA1 digest does not match Crypto's
body: <p>I've spent past 6 hours implementing message signing algorithm.. It does not work AT ALL:</p>
  
  <p>This is PHP code to generate digest:</p>
  
  <pre><code>$payload = "thisisanapple";
  $signature = hash_hmac("sha1", $payload, "thisisarandomkey");
  $data = base64_encode($signature);
  // YzExZWRmZDliMjQzNTZjNzhlNmE3ZTdmMDE3ODJjNmMxMmM4ZTllMQ==
  </code></pre>
  
  <p>This is JS running on the Node.js server doing the same thing:</p>
  
  <pre><code>var hmac = crypto.createHmac('sha1', "thisisarandomkey");
  hmac.update("thisisanapple");
  var signature = hmac.digest('base64');
  // wR7f2bJDVseOan5/AXgsbBLI6eE=
  </code></pre>
  
  <p>I have no clue what is wrong here.. I have tries SHA256, but they still differ. I also used a private key generated with OpenSSL, both in plaintext and in base64, still same result (different keys).</p>