当前位置:网站首页>企业微信官方 加解密库 PHP7版本报错 mcrypt_module_open 未定义方法 并且被PHP抛弃 解决方法使用 openssl解决
企业微信官方 加解密库 PHP7版本报错 mcrypt_module_open 未定义方法 并且被PHP抛弃 解决方法使用 openssl解决
2022-06-12 06:45:00 【fuchto】
官方解密库
加解密库下载与返回码 - 企业号开发者接口文档https://qydev.weixin.qq.com/wiki/index.php?title=%E5%8A%A0%E8%A7%A3%E5%AF%86%E5%BA%93%E4%B8%8B%E8%BD%BD%E4%B8%8E%E8%BF%94%E5%9B%9E%E7%A0%81致命错误: Call to undefined function mcrypt_module_open()
/** * 对密文进行解密 * @param string $encrypted 需要解密的密文 * @return string 解密得到的明文 */ public function decrypt($encrypted, $corpid) { try { //使用BASE64对需要解密的字符串进行解码 $ciphertext_dec = base64_decode($encrypted); // $module = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, ''); $iv = substr($this->key, 0, 16); // mcrypt_generic_init($module, $this->key, $iv); // //解密 // $decrypted = mdecrypt_generic($module, $ciphertext_dec); // mcrypt_generic_deinit($module); // mcrypt_module_close($module); $decrypted = openssl_decrypt($ciphertext_dec, 'AES-256-CBC', $this->key, OPENSSL_RAW_DATA|OPENSSL_ZERO_PADDING, $iv); } catch (Exception $e) { return array(ErrorCode::$DecryptAESError, null); } try { //去除补位字符 $pkc_encoder = new PKCS7Encoder; $result = $pkc_encoder->decode($decrypted); //去除16位随机字符串,网络字节序和AppId if (strlen($result) < 16) return ""; $content = substr($result, 16, strlen($result)); $len_list = unpack("N", substr($content, 0, 4)); $xml_len = $len_list[1]; $xml_content = substr($content, 4, $xml_len); $from_corpid = substr($content, $xml_len + 4); } catch (Exception $e) { print $e; return array(ErrorCode::$IllegalBuffer, null); } if ($from_corpid != $corpid) return array(ErrorCode::$ValidateCorpidError, null); return array(0, $xml_content); }
消息内容解密 报错 Class DOMDocument not found
解决方法:
宝塔示例:
第一步:找到对应网站下 PHP版本

第二步:检查PHP命令版本

使用 命令安装 拓展
我当前版本为 PHP7.4 使用安装命令 为 PHP74w-xml
yum install php74w-xml
系统为 contos8 执行命令时 报错
Error: Unable to find a match: php74w-xml
由于 centos8 已经停止服务
![]()
先升级系统
边栏推荐
- Detailed explanation of convirt paper (medical pictures)
- LeetCode-1154. Day of the year
- SQL injection - Union query
- 六月集训 第七日 ——哈希表
- SQL injection - blind injection
- Oracle Database
- LeetCode-1078. Bigram participle
- leetcode:890. Find and replace mode [two dict records set]
- LeetCode-1629. Key with the longest key duration
- 上位机开发(固件下载软件之需求分析)
猜你喜欢

Upload file (post form submission form data)

Leetcode January 12 daily question 334 Increasing ternary subsequence

VSCode常用插件

【图像检测】基于深度差分和PCANet实现SAR图像变化检测附matlab代码

张驰课堂:2022年CAQ中质协六西格玛考试时间通知

Node. Detailed installation tutorial of CPM and cnpm (including error resolution)

Leetcode January 10 daily question 306 Additive number

Multithreading (2) -- pipeline (2) -- synchronized underlying monitor, lightweight, biased lock, lock inflation

Vscode Common plug - in

SQL injection - blind injection
随机推荐
SQL injection - Union query
【图像检测】基于深度差分和PCANet实现SAR图像变化检测附matlab代码
PHP一句话木马深度详细剖析
A journey of database full SQL analysis and audit system performance optimization
Meituan won the first place in fewclue in the small sample learning list! Prompt learning+ self training practice
五月集训(第28天)——动态规划
The second day of June training - string
VSCode常用插件
leetcode:剑指 Offer 66. 构建乘积数组【前后缀积的应用】
Leetcode: Sword finger offer 63 Maximum profit of stock [record prefix minimum and or no brain segment tree]
sql server 2019安装出现错误,如何解决
leetcode:890. Find and replace mode [two dict records set]
LeetCode-1445. Apples and oranges
【图像去噪】基于偏微分方程(PDE)实现图像去噪附matlab代码
LeetCode-1716. Calculate the amount deducted from the bank
Curry carries the fourth game of the warriors against the Celtics
descheduler 二次调度让 Kubernetes 负载更均衡
Matlab 6-DOF manipulator forward and inverse motion
LeetCode-1185. Day of the week
Redis supports data structure types