开发语言PHP 解密数据代码:
前端代码:
wx.login({
success: res => {
if (res.code) {
request.post(request.api.user.bindTel, {
code: res.code,
encryptedData: detail.encryptedData,
iv: detail.iv
}, {
cookie: cookie.getCookie()
}).then(function(res){
console.log(res)
});
}
},
})
每次获取手机号钱都会调用wx.login这会导致出错吗?
public function decryptData($encryptedData, $iv, $sessionKey)
{
$aesKey=base64_decode($sessionKey);
$aesIV=base64_decode($iv);
$aesCipher=base64_decode($encryptedData);
$result=openssl_decrypt($aesCipher, "AES-128-CBC", $aesKey, 1, $aesIV);
var_dump($result);
$data=json_decode($result, true);
return $data;
}
解密失败。同样的代码昨天是可以正常解密出手机号的