/**
* 工具类
* sKey可自定义
*/
//加密
export let enCode=(plaintText)=>{
var that = this
// var CryptoJS = require("crypto-js");
var sKey = "abc123456789"
sKey = CryptoJS.enc.Utf8.parse(sKey)
var ciphertext = CryptoJS.AES.encrypt(plaintText, sKey, {
iv: sKey,
mode: CryptoJS.mode.CBC, // CBC算法
padding: CryptoJS.pad.ZeroPadding, //使用pkcs7 进行padding 后端需要注意
}).toString();
return ciphertext;
}
//解密
export let deCode=(ciphertext)=>{
var sKey = "abc123456789"
// var CryptoJS = require("crypto-js");
sKey = CryptoJS.enc.Utf8.parse(sKey)
return CryptoJS.AES.decrypt(ciphertext, sKey, {
iv: sKey,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
}).toString(CryptoJS.enc.Utf8);
}