title: NodeJS - SHA256 Password Encryption
body: <p>I'm currently learning about encryption and password safety in NodeJS. I'm working with a current example that currently is using PBKDF2, I'd like to switch this out to use SHA256 instead. Is this possible and/or make sense? How would I go about it?</p>
  
  <pre><code>var crypto = require('crypto');
  
  var len = 128;
  
  var iterations = 13000;
  
  module.exports = function (pwd, salt, fn) {
    if (3 == arguments.length) {
      crypto.pbkdf2(pwd, salt, iterations, len, fn);
    } else {
      fn = salt;
      crypto.randomBytes(len, function(err, salt){
        if (err) return fn(err);
        salt = salt.toString('base64');
        crypto.pbkdf2(pwd, salt, iterations, len, function(err, hash){
          if (err) return fn(err);
          fn(null, salt, hash);
        });
      });
    }
  };
  </code></pre>