Beispiel #1
0
def makeSignedArguments(params, signKey, signSecret, body):

    params[b'timestamp'] = [network_string(_utcnow())]
    params[b'seq'] = [b"1"]
    params[b'key'] = [network_string(signKey)]
    params[b'nonce'] = [network_string(str(random.randint(0, 9007199254740992)))]

    # HMAC[SHA256]_{secret} (key | timestamp | seq | nonce | body) => signature

    hm = hmac.new(signSecret.encode('utf8'), None, hashlib.sha256)
    hm.update(params[b'key'][0])
    hm.update(params[b'timestamp'][0])
    hm.update(params[b'seq'][0])
    hm.update(params[b'nonce'][0])
    hm.update(body)
    signature = base64.urlsafe_b64encode(hm.digest())
    params[b'signature'] = [signature]

    return params
def makeSignedArguments(params, signKey, signSecret, body):

    params[b'timestamp'] = [network_string(_utcnow())]
    params[b'seq'] = [b"1"]
    params[b'key'] = [network_string(signKey)]
    params[b'nonce'] = [
        network_string(str(random.randint(0, 9007199254740992)))
    ]

    # HMAC[SHA256]_{secret} (key | timestamp | seq | nonce | body) => signature

    hm = hmac.new(signSecret.encode('utf8'), None, hashlib.sha256)
    hm.update(params[b'key'][0])
    hm.update(params[b'timestamp'][0])
    hm.update(params[b'seq'][0])
    hm.update(params[b'nonce'][0])
    hm.update(body)
    signature = base64.urlsafe_b64encode(hm.digest())
    params[b'signature'] = [signature]

    return params