FIX AES 加密无效

This commit is contained in:
sakuya 2021-09-21 10:16:14 +08:00
parent 591847e299
commit 3b99ab5399
1 changed files with 8 additions and 2 deletions

View File

@ -138,11 +138,17 @@ tool.crypto = {
//AES加解密
AES: {
encrypt(data, secretKey){
const result = CryptoJS.AES.encrypt(data, CryptoJS.enc.Utf8.parse(secretKey))
const result = CryptoJS.AES.encrypt(data, CryptoJS.enc.Utf8.parse(secretKey), {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
})
return result.toString()
},
decrypt(cipher, secretKey){
const result = CryptoJS.AES.decrypt(cipher, CryptoJS.enc.Utf8.parse(secretKey))
const result = CryptoJS.AES.decrypt(cipher, CryptoJS.enc.Utf8.parse(secretKey), {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
})
return CryptoJS.enc.Utf8.stringify(result);
}
}