function getAesString(data,key,iv){//加密
var key = CryptoJS.enc.Utf8.parse(key);
var iv = CryptoJS.enc.Utf8.parse(iv);
var encrypted =CryptoJS.AES.encrypt(data,key,
{
iv:iv,
mode:CryptoJS.mode.CBC,
padding:CryptoJS.pad.Pkcs7
});
return encrypted.toString(); //返回的是base64格式的密文
}
function getDAesString(encrypted,key,iv){//解密
var key = CryptoJS.enc.Utf8.parse(key);
var iv = CryptoJS.enc.Utf8.parse(iv);
var decrypted =CryptoJS.AES.decrypt(encrypted,key,
{
iv:iv,
mode:CryptoJS.mode.CBC,
padding:CryptoJS.pad.Pkcs7
});
return decrypted.toString(CryptoJS.enc.Utf8);
}
function getAES(data,key){ //加密
// var key = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'; //密钥
realKey = Base64.encode(key);
var iv = '1234567812345678';
var encrypted =getAesString(data,realKey,iv); //密文
var
jsAES128加密方法
最新推荐文章于 2024-07-16 08:49:00 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)