//引入组件
var crypto = require('crypto');
//加密
var aesEncrypt = function (data, secretKey) {
var cipher = crypto.createCipher('aes-128-ecb', secretKey);
return cipher.update(data, 'utf8', 'hex') + cipher.final('hex');
}
//解密
var aesDecrypt = function (data, secretKey) {
var cipher = crypto.createDecipher('aes-128-ecb', secretKey);
return cipher.update(data, 'hex', 'utf8') + cipher.final('utf8');
}
//解密(传入已加密的密码和自定义的解密key)
var db_password = aesDecrypt(password, "1234567887654321");
//加密(传入需要加密的密码和自定义的加密key)
var new_password = aesEncrypt(password, "1234567887654321");
console.log(db_password)
console.log(new_password)
console