// import CryptoJS from 'crypto-js' //引用AES源码js
// const key = CryptoJS.enc.Utf8.parse("d86d7bab3d6ac01ad9dc6a897652f2d2"); //十六位十六进制数作为密钥
var key = "838246ca245c2a75cd66569ebf7c7181"; //十六位十六进制数作为密钥
// const iv = CryptoJS.enc.Utf8.parse('1234567812345678'); //十六位十六进制数作为密钥偏移量
// console.log(CryptoJS.enc.Hex.parse(key))
//解密方法
function Decrypt(text) {
var result = CryptoJS.AES.decrypt(text,CryptoJS.enc.Hex.parse(key),{
mode:CryptoJS.mode.ECB,
padding:CryptoJS.pad.Pkcs7
})
// return result.toString(CryptoJS.enc.Utf8)
return CryptoJS.enc.Utf8.stringify(result).toString();
}
//加密方法
function Encrypt(text) {
var srcs = CryptoJS.enc.Utf8.parse(text);
let encrypted = CryptoJS.AES.encrypt(srcs, CryptoJS.enc.Hex.parse(key), { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 });
return encrypted
}
// var text={
// id:666,
// name:"三生三世"
// }
// var encoded=Encrypt(JSON.stringify(text))
// console.log(encoded.toString());
var res ="3PsjPR/8bhyEL9HO5fXyayNlGojesH0ZbmKL4X/U88A23yDmxQB9Yrnh7lkW5Dwx+h9LpzB62GDbAO7kdUiKra0WTRyJhYNtoO3PBvTXuTVX2Ho8skhPB0axfbms+pNrNG6gKGLHh3nAC3Jytba2M5F3RIhu6qEJcauHVetVlCoLGnoDEhVpK9CkfXg/kNZPWJVCSprA3TnNWP5pg7gtmXOo5ry+GVsHREV2zHkBaT9nwHP8/mhAw1GTcBFR0N4g"
console.log(Decrypt(res))
console