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.
37 lines
1013 B
37 lines
1013 B
let CryptoJS = require('../plugins/crypto-js')
|
|
|
|
//进行密码的加密
|
|
module.exports = {
|
|
/**
|
|
* 加密
|
|
* @param {string} word
|
|
* @returns {string}
|
|
*/
|
|
aesMinEncrypt(word) {
|
|
let _word = CryptoJS.enc.Utf8.parse(word),
|
|
_key = CryptoJS.enc.Utf8.parse("{g;,9~lde^[w`com"),
|
|
_iv = CryptoJS.enc.Utf8.parse("$JL<&*lZFsZ?:cjy");
|
|
let encrypted = CryptoJS.AES.encrypt(_word, _key, {
|
|
iv: _iv,
|
|
mode: CryptoJS.mode.CBC,
|
|
padding: CryptoJS.pad.Pkcs7
|
|
});
|
|
return encrypted.toString();
|
|
},
|
|
|
|
/**
|
|
* 解密
|
|
* @param {string} word
|
|
* @returns {string}
|
|
*/
|
|
aesDecrypt(word) {
|
|
var _key = CryptoJS.enc.Utf8.parse("{g;,9~lde^[w`com"),
|
|
_iv = CryptoJS.enc.Utf8.parse("$JL<&*lZFsZ?:cjy");
|
|
var decrypted = CryptoJS.AES.decrypt(word, _key, {
|
|
iv: _iv,
|
|
mode: CryptoJS.mode.CBC,
|
|
padding: CryptoJS.pad.Pkcs7
|
|
});
|
|
return decrypted.toString(CryptoJS.enc.Utf8);
|
|
}
|
|
}
|
|
|