title: how to encrypt-decrypt Node.js Crypto aes256 Cipher
body: <p>i have to encrypt password string inside javascript front-code and using $.ajax i used to send that encrypted password in node.js but i dont know how to decrypt that password inside node.js</p>
  
  <p>i got one example with node.js but how can i use encryption code with javascript(front-end) and do the same decryption given in bellow code.</p>
  
  <pre><code>var crypto = require('crypto');
  
  var algorithm = 'aes256'; // or any other algorithm supported by OpenSSL
  var key = 'password';
  var text = 'I love kittens';
  
  var cipher = crypto.createCipher(algorithm, key);  
  var encrypted = cipher.update(text, 'utf8', 'hex') + cipher.final('hex');
  var decipher = crypto.createDecipher(algorithm, key);
  var decrypted = decipher.update(encrypted, 'hex', 'utf8') + decipher.final('utf8');
  
  console.log(decrypted);
  </code></pre>