微信后台服务器地址验证的逻辑
不说废话了,直接上py3 django代码:
token = "-----------------------------"#自己填到微信设置里面的token nonce = request.GET["nonce"] timestamp = request.GET["timestamp"] msg_sign = request.GET["signature"] arr1 = [token,timestamp,nonce] arr1.sort() tempstr = "".join(arr1) sha1 = hashlib.sha1() sha1.update(tempstr.encode('utf-8')) compute_sign = sha1.hexdigest() if msg_sign == compute_sign: return HttpResponse(request.GET["echostr"])