AesKey = '1234567890123456';//加密时用的key,跟php一样
AesIv='8NONwyJtHesysWpM';//iv 偏移量
var data='ABCDEFGH';
var key = CryptoJS.enc.Utf8.parse(AesKey);
var iv = CryptoJS.enc.Utf8.parse(AesIv);
var encrypted = CryptoJS.AES.encrypt(data, key, { iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 });
var msg = encrypted.toString();//结果为加密后的字符串
console.log("加密后:"+msg);
var bytes = CryptoJS.AES.decrypt(msg, key,{ iv: iv, padding: CryptoJS.pad.Pkcs7 });
var originalText = bytes.toString(CryptoJS.enc.Utf8);
console.log("解密后:"+originalText);