I am using following functions to encrypt/decrypt strings in Node.js:
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;
}
(password is stored separately from encoded text). New version of nodejs/crypt package complains:
(node:5212) [DEP0106] DeprecationWarning: crypto.createDecipher is deprecated.
How do I rewrite this to upgrade my source code?