BlueWallet/encryption.js

16 lines
393 B
JavaScript
Raw Normal View History

2018-03-30 20:31:10 +02:00
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);
2018-04-01 01:16:42 +02:00
let str = false;
try {
str = bytes.toString(CryptoJS.enc.Utf8);
} catch (e) {}
return str;
2018-03-30 20:31:10 +02:00
};