Skip to content

Commit f20767a

Browse files
authored
Add files via upload
测试解密
1 parent 0af1ebe commit f20767a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

callback_json_python3/Sample.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#########################################################################
99
from WXBizJsonMsgCrypt import WXBizJsonMsgCrypt
1010
import sys
11+
import json
1112

1213
if __name__ == "__main__":
1314
#假设企业在企业微信后台上设置的参数如下
@@ -106,3 +107,17 @@
106107
print(sEncryptMsg)
107108
#ret == 0 加密成功,企业需要将sEncryptMsg返回给企业号
108109
print("==============================")
110+
111+
'''
112+
对上面加密的包进行解密
113+
'''
114+
sReqMsgSig = json.loads(sEncryptMsg)['msgsignature']
115+
sReqTimeStamp = json.loads(sEncryptMsg)['timestamp']
116+
sReqNonce = json.loads(sEncryptMsg)['nonce']
117+
118+
ret,sMsg=wxcpt.DecryptMsg( sEncryptMsg, sReqMsgSig, sReqTimeStamp, sReqNonce)
119+
if( ret!=0 ):
120+
print("ERR: DecryptMsg ret: " + str(ret))
121+
sys.exit(1)
122+
else:
123+
print(sMsg)

0 commit comments

Comments
 (0)