MCPcopy Create free account
hub / github.com/doraemonext/wechat-python-sdk / check_signature

Method check_signature

wechat_sdk/basic.py:92–109  ·  view source on GitHub ↗

验证微信消息真实性 :param signature: 微信加密签名 :param timestamp: 时间戳 :param nonce: 随机数 :return: 通过验证返回 True, 未通过验证返回 False

(self, signature, timestamp, nonce)

Source from the content-addressed store, hash-verified

90 self.__request = request
91
92 def check_signature(self, signature, timestamp, nonce):
93 """
94 验证微信消息真实性
95 :param signature: 微信加密签名
96 :param timestamp: 时间戳
97 :param nonce: 随机数
98 :return: 通过验证返回 True, 未通过验证返回 False
99 """
100 if not signature or not timestamp or not nonce:
101 return False
102
103 tmp_list = [self.conf.token, timestamp, nonce]
104 tmp_list.sort()
105 tmp_str = ''.join(tmp_list)
106 if signature != hashlib.sha1(tmp_str.encode('utf-8')).hexdigest():
107 return False
108
109 return True
110
111 def generate_jsapi_signature(self, timestamp, noncestr, url, jsapi_ticket=None):
112 """

Callers 3

test_check_signatureMethod · 0.95

Calls 1

encodeMethod · 0.45

Tested by 1

test_check_signatureMethod · 0.76