You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
393 B

7 years ago
let CryptoJS = require('crypto-js');
module.exports.encrypt = function(data, password) {
let ciphertext = CryptoJS.AES.encrypt(data, password);
return ciphertext.toString();
};
module.exports.decrypt = function(data, password) {
let bytes = CryptoJS.AES.decrypt(data, password);
let str = false;
try {
str = bytes.toString(CryptoJS.enc.Utf8);
} catch (e) {}
return str;
7 years ago
};