js加解密

创建加密算法

1
2
3
4
5
6
const aseEncode = function(data, password) {
const cipher = crypto.createCipher('aes192', password);
let crypted = cipher.update(data, 'utf-8', 'hex');
crypted += cipher.final('hex');
return crypted;
};

创建解密算法

1
2
3
4
5
6
const aseDecode = function(data, password) {
const decipher = crypto.createDecipher('aes192', password);
let decrypted = decipher.update(data, 'hex', 'utf-8');
decrypted += decipher.final('utf-8');
return decrypted;
};