示例#1
0
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 '{}&timestamp={}&sign={}'.format(webhook, timestamp, sign)
示例#2
0
文件: http.py 项目: stoneLeaf/aimable
def quote_plus(s):
    return _quote_plus(to_utf8(s))
示例#3
0
文件: http.py 项目: TZer0/botmily
def quote_plus(s):
	return _quote_plus(to_utf8(s))
示例#4
0
文件: compat.py 项目: guix77/weboob
 def quote_plus(p, *args, **kwargs):
     return _quote_plus(_reencode(p), *args, **kwargs)
示例#5
0
 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)
示例#6
0
文件: compat.py 项目: P4ncake/weboob
 def quote_plus(p, *args, **kwargs):
     return _quote_plus(_reencode(p), *args, **kwargs)