对于PHP7与CryptoJS的AES加密的方式互通代码不能正确执行,我的测试代码为:JS端:let iv = CryptoJS.enc.Utf8.parse('1111111111111111');let key = CryptoJS.enc.Utf8.parse('201707eggplant99')
console.log(CryptoJS.AES.encrypt(JSON.stringify({name:1}),key ,{
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.ZeroPadding,
iv: iv
}).toString().toUpperCase())//输出:NZPBWAEV91QMVH67TQE+OA==PHP端:$privateKey = "201707eggplant99";$iv = "1111111111111111";$encryptedData = base64_decode("NZPBWAEV91QMVH67TQE+OA==");$decrypted = openssl_decrypt($encryptedData,"AES-128-CBC",$privateKey,OPENSSL_ZERO_PADDING ,$iv);
var_dump($decrypted);//输出:bool(false)求解答,到底是哪儿出了问题导致不能进行互相加密与解密?
- 2 回答
- 1 关注
- 1886 浏览
添加回答
举报
0/150
提交
取消