From f20767a3e091e43c20fbd351a6789e7fe846593d Mon Sep 17 00:00:00 2001 From: sbzhu Date: Wed, 16 Jul 2025 14:12:44 +0800 Subject: [PATCH] Add files via upload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 测试解密 --- callback_json_python3/Sample.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/callback_json_python3/Sample.py b/callback_json_python3/Sample.py index 740de23..31e2618 100644 --- a/callback_json_python3/Sample.py +++ b/callback_json_python3/Sample.py @@ -8,6 +8,7 @@ ######################################################################### from WXBizJsonMsgCrypt import WXBizJsonMsgCrypt import sys +import json if __name__ == "__main__": #假设企业在企业微信后台上设置的参数如下 @@ -106,3 +107,17 @@ if __name__ == "__main__": print(sEncryptMsg) #ret == 0 加密成功,企业需要将sEncryptMsg返回给企业号 print("==============================") + + ''' + 对上面加密的包进行解密 + ''' + sReqMsgSig = json.loads(sEncryptMsg)['msgsignature'] + sReqTimeStamp = json.loads(sEncryptMsg)['timestamp'] + sReqNonce = json.loads(sEncryptMsg)['nonce'] + + ret,sMsg=wxcpt.DecryptMsg( sEncryptMsg, sReqMsgSig, sReqTimeStamp, sReqNonce) + if( ret!=0 ): + print("ERR: DecryptMsg ret: " + str(ret)) + sys.exit(1) + else: + print(sMsg)