title: How do I replace deprecated crypto.createCipher in Node.js?
body: <p>I am using following functions to encrypt/decrypt strings in Node.js:</p>
  <pre class="lang-js prettyprint-override"><code>var crypto = require('crypto');
  var algorithm = 'aes-256-ctr';
  function encrypt(text) {
      var cipher = crypto.createCipher(algorithm, password);
      try {
          var crypted = cipher.update(text, 'utf8', 'hex');
          crypted += cipher.final('hex');
      } catch (e) {
          return;
      }
      return crypted;
  }
  
  function decrypt(text) {
      var decipher = crypto.createDecipher(algorithm, password);
      try {
          var dec = decipher.update(text, 'hex', 'utf8');
          dec += decipher.final('utf8');
      } catch (e) {
          return;
      }
      return dec;
  }
  </code></pre>
  <p>(password is stored separately from encoded text). New version of nodejs/crypt package complains:</p>
  <pre><code>(node:5212) [DEP0106] DeprecationWarning: crypto.createDecipher is deprecated.
  </code></pre>
  <p>How do I rewrite this to upgrade my source code?</p>