公司演示版e鹿悦游
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.
 
 
 
 
 
CjyTravel/plugin/util/EncryptUtil.js

36 lines
1.1 KiB

let CryptoJS = require('../../plugin/node_modules/crypto-js')
//进行密码的加密
export default {
/**
* 加密
* @param {string} word
* @returns {string}
*/
aesMinEncrypt(word) {
let _word = CryptoJS.enc.Utf8.parse(word),
_key = CryptoJS.enc.Utf8.parse("{g;,9~lde^[w`cjy"),
_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}
*/
aesMinDecrypt(word) {
let encryptedHexStr = CryptoJS.enc.Hex.parse(word);
let _sercs = CryptoJS.enc.Base64.stringify(encryptedHexStr),
_key = CryptoJS.enc.Utf8.parse("{g;,9~lde^[w`cjy"),
_iv = CryptoJS.enc.Utf8.parse("$JL<&*lZFsZ?:cjy");
let decrypt = CryptoJS.AES.decrypt(_sercs, _key, { iv: _iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 });
let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
return decryptedStr.toString();
}
}