const iv = Buffer.from('aeghei1Di8tieNg0');
exports.encrypt = function(text, password){
try {
var cipher = crypto.createCipheriv('aes-128-cbc',password,iv);
var crypted = cipher.update(text,'utf8','hex');
crypted += cipher.final('hex');
return crypted;
} catch (err) {
console.error('encrypt error',err);
return null;
}
};
exports.decrypt = function(text, password){
try {
var decipher = crypto.createDecipheriv('aes-128-cbc',password,iv);
var dec = decipher.update(text,'hex','utf8');
dec += decipher.final('utf8');
return dec;
} catch (err) {
console.error('decrypt error',err);
return null;
}
}; |
const iv = Buffer.from('aeghei1Di8tieNg0');
exports.encrypt = function(text, password){
try {
var cipher = crypto.createCipheriv('aes-128-cbc',password,iv);
var crypted = cipher.update(text,'utf8','hex');
crypted += cipher.final('hex');
return crypted;
} catch (err) {
console.error('encrypt error',err);
return null;
}
};
exports.decrypt = function(text, password){
try {
var decipher = crypto.createDecipheriv('aes-128-cbc',password,iv);
var dec = decipher.update(text,'hex','utf8');
dec += decipher.final('utf8');
return dec;
} catch (err) {
console.error('decrypt error',err);
return null;
}
};