title: Node SHA-256 Base64 Digest
body: <p>I have a question about Node.js Crypto module's hash digest.</p>
  
  <p>With the input <code>hello world</code> on the command line a base64 encoded sha256 produces:</p>
  
  <pre><code>$ echo -n "hello world"|shasum -a256|base64 -
  Yjk0ZDI3Yjk5MzRkM2UwOGE1MmU1MmQ3ZGE3ZGFiZmFjNDg0ZWZlMzdhNTM4MGVlOTA4OGY3YWNlMmVmY2RlOSAgLQo=
  </code></pre>
  
  <p>Doing the same (as far as I know) on Node.js (0.12.9) produces an entirely different result:</p>
  
  <pre><code>var crypto = require("crypto");
  var shasum = crypto.createHash("sha256"); 
  shasum.update("hello world", "utf-8"); 
  shasum.digest("base64");
  // 'uU0nuZNNPgilLlLX2n2r+sSE7+N6U4DukIj3rOLvzek='
  </code></pre>
  
  <p>The hex digest procuced in Node and on the command line are identical (<code>b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9</code>). Why the difference in the base64 encoded digest?</p>