You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
908 B

<?php
namespace tencent\wechat\mpweixin;
use EasyWeChat\Factory;
class Decrypt extends Base
{
/**
* 数据解密
* @param string $session 用户的会话密钥
* @param string $iv 加密算法的初始向量
* @param string dump($param['encrypted_data']); 包括敏感数据在内的完整用户信息的加密数据
* @date 2022-10-18
*/
public function decryptData($session, $iv, $encrypted_data)
{
$app = Factory::miniProgram($this->mpWeixinConfig);
// 微信小程序消息解密
$data = $app->encryptor->decryptData($session, $iv, $encrypted_data);
// 记录日志
$uid = defined('UID') ? UID : '';
platformLog([
'session' => $session,
'iv' => $iv,
'encrypted_data' => $encrypted_data
], $data, 'mpweixin_decrypt_data_uid_' . $uid);
return $data;
}
}