这篇文章主要介绍了PHP解密支付宝小程序的加密数据、手机号的示例代码,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
1、小程序端代码示例my.getPhoneNumber({
success: (res) => {
let encryptedData = res.response;
my.httpRequest({
url: '你的后端服务端',
data: encryptedData,
});
},
fail: (res) => {
console.log(res);
console.log('getPhoneNumber_fail');
},
});
2、PHP后端解密示例public static function decryptData($encryptedData, $key = '开发设置-接口内容加密方式-查看-字符串')
{
$encrys = json_decode($encryptedData, true);
$encryptedData = $encrys['response'];
$str = base64_decode($encryptedData);
$screct_key = base64_decode($key);
//设置全0的IV
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
$iv &#