联系我们:416326801#qq.com(#改成@)

Latest from the blog

微信支付退款结果通知解密

标签: PHP Weixin wxpay

微信支付退款结果通知解密步骤如下: 

第一步,对商户密钥key进行MD5加密,得到32位小写加密串StringA

key设置路径:微信商户平台(pay.weixin.qq.com)-->账户设置-->API安全-->密钥设置 

第二步,使用StringA作为key,对参数加密串进行AES-256(ECB模式,PKCS7Padding)解密,得到加密前参数。


第一步很好理解, 第二步微信并没有给出demo, 经测试可用的PHP代码如下

注意:示例函数的$key不是商户秘钥,需要事先进行MD5加密

明文=refund_decrypt(密文,MD5(商户秘钥));

$refund_xml_string = refund_decrypt($weixin_post_string, md5($weixin_key));

function refund_decrypt($str, $key) {
        $str = base64_decode($str);
        $str = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $str, MCRYPT_MODE_ECB);
        $block = mcrypt_get_block_size('rijndael_128', 'ecb');
        $pad = ord($str[($len = strlen($str)) - 1]);
        $len = strlen($str);
        $pad = ord($str[$len - 1]);
        return substr($str, 0, strlen($str) - $pad);
}

解密结果示例

解密后:

<root>
<out_refund_no><![CDATA[R4001312001201707262674894706_4]]></out_refund_no>
<out_trade_no><![CDATA[201707260201501501005710775]]></out_trade_no>
<refund_account><![CDATA[REFUND_SOURCE_UNSETTLED_FUNDS]]></refund_account>
<refund_fee><![CDATA[15]]></refund_fee>
<refund_id><![CDATA[50000203702017072601461713166]]></refund_id>
<refund_recv_accout><![CDATA[用户零钱]]></refund_recv_accout>
<refund_request_source><![CDATA[API]]></refund_request_source>
<refund_status><![CDATA[SUCCESS]]></refund_status>
<settlement_refund_fee><![CDATA[15]]></settlement_refund_fee>
<settlement_total_fee><![CDATA[100]]></settlement_total_fee>
<success_time><![CDATA[2017-07-26 02:45:49]]></success_time>
<total_fee><![CDATA[100]]></total_fee>
<transaction_id><![CDATA[4001312001201707262674894706]]></transaction_id>
</root>

退款结果图:

微信支付退款测试.jpg

rm -rf 删除后急救

标签: Linux rm

附件下载: extundelete-0.2.4.tar.bz2

可能依赖: yum install e2fsprogs    yum install e2fslibs

tar -jxvf extundelete-0.2.4.tar.bz2
cd extundelete-0.2.4
./configure 
make && make install

# 测试是否安装成功
extundelete -v

# 查看分区
df -h

# 恢复文件
cd $dir
extundelete /dev/mapper/VolGroup-lv_root --restore-directory '/home'
extundelete /dev/mapper/VolGroup-lv_root  --restore-all

# 查看文件
cd RECOVERED_FILES/

{"errcode":45047,"errmsg":"out of response count limit hint]"}

标签: Weixin

微信公众号发送客服消息返回错误码45047, 官方并没有给出45047的具体含义.

根据字面意思和测试结果, 该错误值代表: 对同一用户频发发送客服消息超过限制, 避免对用户造成骚扰. 

一般只会发调试的时候出现, 解决办法: 接收人给公众号发条消息, 或者换个openid测试. 

Fatal error: cannot allocate memory for the buffer pool

标签: MySQL

今天线上数据库异常挂了两次,查看日志发现致命错误Fatal error: cannot allocate memory for the buffer pool

修改/etc/my.cnf,适当降低innodb_buffer_pool_size参数值,从256M调整为128M

170602 17:51:27 mysqld_safe Number of processes running now: 0
170602 17:51:27 mysqld_safe mysqld restarted
170602 17:51:27 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.5.48-log) starting as process 3476 ...
170602 17:51:27 InnoDB: The InnoDB memory heap is disabled
170602 17:51:27 InnoDB: Mutexes and rw_locks use GCC atomic builtins
170602 17:51:27 InnoDB: Compressed tables use zlib 1.2.7
170602 17:51:27 InnoDB: Initializing buffer pool, size = 256.0M
170602 17:51:27 InnoDB: Completed initialization of buffer pool
170602 17:51:27 InnoDB: Fatal error: cannot allocate memory for the buffer pool
170602 17:51:27 [ERROR] Plugin 'InnoDB' init function returned error.
170602 17:51:27 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
170602 17:51:27 [ERROR] Unknown/unsupported storage engine: InnoDB
170602 17:51:27 [ERROR] Aborting
170602 17:51:27 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete
170602 17:51:27 mysqld_safe mysqld from pid file /data/mysql/yuxinle.pid ended


贴上几个关键指标,供以后出现同类问题时参考

mysql> show global variables like 'innodb_buffer_pool_size';
+-------------------------+-----------+
| Variable_name           | Value     |
+-------------------------+-----------+
| innodb_buffer_pool_size | 134217728 |
+-------------------------+-----------+
1 row in set (0.00 sec)

mysql> show global status like 'Innodb_buffer_pool_pages_data';
+-------------------------------+-------+
| Variable_name                 | Value |
+-------------------------------+-------+
| Innodb_buffer_pool_pages_data | 574   |
+-------------------------------+-------+
1 row in set (0.00 sec)

mysql> show global status like 'Innodb_buffer_pool_pages_total';
+--------------------------------+-------+
| Variable_name                  | Value |
+--------------------------------+-------+
| Innodb_buffer_pool_pages_total | 8191  |
+--------------------------------+-------+
1 row in set (0.00 sec)

mysql> show global status like 'Innodb_page_size';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| Innodb_page_size | 16384 |
+------------------+-------+
1 row in set (0.00 sec)

mysql> show variables like 'max_connections';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 3000  |
+-----------------+-------+
1 row in set (0.00 sec)

mysql>  show global status like 'Max_used_connections';
+----------------------+-------+
| Variable_name        | Value |
+----------------------+-------+
| Max_used_connections | 4     |
+----------------------+-------+
1 row in set (0.00 sec)

Linux修改密码提示passwd /usr/share/cracklib/pw_dict: error reading header

标签: Linux rpm

今天在修改一台Linux服务器密码时出现提示

/usr/share/cracklib/pw_dict: error reading header

/usr/share/cracklib/pw_dict.pwd: No such file or directory

这是因为cracklib-dicts函数库出问题了,先查看下版本

rpm -qa | grep cracklib-dicts
cracklib-dicts-2.8.9-3.3
卸载安装包并重装
rpm -e cracklib-dicts --nodeps
yum install cracklib-dicts
如果yum install安装失败,可以尝试安装rpm包
rpm -ivh cracklib-dicts-2.8.9-3.3.x86_64.rpm 

rpm -ql cracklib-dicts检查下是否安装成功

rpm -ql cracklib-dicts
/usr/lib64/cracklib_dict.hwm
/usr/lib64/cracklib_dict.pwd
/usr/lib64/cracklib_dict.pwi
/usr/sbin/mkdict
/usr/sbin/packer
/usr/share/cracklib
/usr/share/cracklib/pw_dict.hwm
/usr/share/cracklib/pw_dict.pwd
/usr/share/cracklib/pw_dict.pwi

rpm包可以在光盘镜像Server目录中找到, 最好安装相同,否则有可能产生依赖问题,拔出萝卜带出泥....

cracklib-dicts-2.9.6-5.fc26.x86_64.zip


CrackLib是一个可用于类UNIX系统下的函数库,   一般来说,   通常只使用其中的一个函数.它可以用于编写和passwd有关的程序中,   其基本思想是很简单的,   就是防止用户使用过于简单,   容易被猜测出来或容易被一些工具搜索到的密码.CrackLib并不是一个可以直接运行使用的程序,   它是一个函数库,   你可以利用其中的函数写自己的程序,   或是加入其它程序中,   用来提高安全性。

1 2 3 4 5 6 7 8 9 ... Next »... Last »