当前位置:网站首页>企业微信官方 加解密库 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 已经停止服务
![]()
先升级系统
边栏推荐
- Use ms17-010 Eternal Blue vulnerability to infiltrate win7 and establish a permanent back door
- The seventh day of June training - hash table
- Codeforces Round #793 (Div. 2) A B C
- leetcode 704. Binary search
- The difference between get and post and the code implementation of message board
- An error occurred while downloading the remote file The errormessage
- 2 variables and basic types
- MySQL multiple SQL batch operations (crud) in JDBC
- [easyexcel] easyexcel checks whether the header matches the tool class encapsulated in easyexcel, including the field verification function. You can use validate to verify
- Multithreading Foundation (XI) -- prevent CPU from occupying 100%
猜你喜欢

2021 robocom world robot developer competition - undergraduate group (Preliminary)

CL210OpenStack操作的故障排除--章節實驗
![[data clustering] data set, visualization and precautions are involved in this column](/img/46/0b4918ef9c9301fbc374913fe806de.png)
[data clustering] data set, visualization and precautions are involved in this column

2 variables and basic types

SQL 注入-盲注

PHP一句话木马深度详细剖析

【图像去噪】基于高斯滤波、均值滤波、中值滤波、双边滤波四种滤波实现椒盐噪声图像去噪附matlab代码

LeetCode-419. Battleship on deck

【图像去噪】基于非局部欧几里德中值 (NLEM) 实现图像去噪附matlab代码

(14) The software version number is displayed in the flash window of blender source code analysis
随机推荐
【图像检测】基于深度差分和PCANet实现SAR图像变化检测附matlab代码
CL210OpenStack操作的故障排除--章节实验
LeetCode-1629. Key with the longest key duration
LeetCode-1490. Clone n-ary tree
Install MySQL tutorial
Solution: content type 'application/x-www-form-urlencoded; charset=UTF-8‘ not supported
2 variables and basic types
美团获得小样本学习榜单FewCLUE第一!Prompt Learning+自训练实战
六月集训 第五天——双指针
Multithreading (V) -- Concurrent tools (II) -- j.u.c concurrent contracting (I) -- AQS and reentrantlock principles
LeetCode-1445. Apples and oranges
Some operations of MATLAB array
2021 RoboCom 世界机器人开发者大赛-本科组(初赛)
The second day of June training - string
Qt-- realize TCP communication
Multithreading (V) -- concurrency tools (I) -- thread pool (II) -- related contents of ThreadPoolExecutor
6 functions
LeetCode-1873. Calculate special bonus
How to build your own website (using the pagoda panel)
leetcode. 39 --- combined sum