title: How to get first 16 bytes of an SHA1 hash in node.js?
body: <p>I'm trying to interoperate with a Java server.  As part of the protocol, I need to create a SHA1 hash of my content.  For some reason, only the first 16 bytes of the hash digest are used, encoded in Base64.  The message digest is an array of bytes in Java, and it's truncated to length 16 before being Base64 encoded.</p>
  <p>How can I do the same in javascript on node?  I'm using the built in node crypto, but the digest is not simply an array. How can I access the hash value and retrieve the first 16 bytes?
  The following code gives me 20 bytes:</p>
  <pre class="lang-js prettyprint-override"><code>var crypto = require('crypto');
  var hash = crypto.createHash('sha1');
  data = hash.update('This is the password', 'utf-8');
  gen_hash= data.digest('base64');
  console.log(gen_hash);
  </code></pre>