let encryptKey = CryptoJS.enc.Utf8.parse('CJAVAPmXcuAksWmF'),
encryptIV = CryptoJS.enc.Utf8.parse('V33CQ1428SI8ZNMT')
//加密值,转成Base64确保不包含特殊字符
const encryptByAES = (value) => {
const text = CryptoJS.AES.encrypt(CryptoJS.enc.Utf8.parse(value), encryptKey, {
iv: encryptIV,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
}).toString()
return CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(text))
}
//解密值
const decryptByAES = (text) => {
const value= CryptoJS.enc.Utf8.stringify(CryptoJS.enc.Base64.parse(text))
let decrypted = CryptoJS.AES.decrypt(value, encryptKey, {
iv: encryptIV,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
});
return decrypted.toString(CryptoJS.enc.Utf8)
}
jquery实现CryptoJS.AES加密解密,加密值不带特殊字符
最新推荐文章于 2024-07-03 13:40:05 发布