def _signature(webhook, secret, var = sys.version_info.major): 'signture the url with the secret' timestamp = long(round(time.time() * 1000)) if(var==2)else str(round(time.time() * 1000)) secret_enc = bytes(secret).encode('utf-8') if(var==2)else secret.encode('utf-8') string_to_sign = '{}\n{}'.format(timestamp, secret) string_to_sign_enc = bytes(string_to_sign).encode('utf-8') if(var==2)else string_to_sign.encode('utf-8') hmac_code = hmac.new(secret_enc, string_to_sign_enc, digestmod=hashlib.sha256).digest() sign = _quote_plus(base64.b64encode(hmac_code)) return '{}×tamp={}&sign={}'.format(webhook, timestamp, sign)
def quote_plus(s): return _quote_plus(to_utf8(s))
def quote_plus(s): return _quote_plus(to_utf8(s))
def quote_plus(p, *args, **kwargs): return _quote_plus(_reencode(p), *args, **kwargs)
def quote_plus(string, safe=b''): if not isinstance(safe, bytes): safe = safe.encode('ascii', 'ignore') if not isinstance(string, bytes): string = string.encode('utf8') return _quote_plus(string, safe)
def quote_plus(p, *args, **kwargs): return _quote_plus(_reencode(p), *args, **kwargs)