Ucloud 签名算法

import requests
import hashlib, json, http.client
import urllib.parse
import urllib.request, urllib.parse, urllib.error


def _verfy_ac(private_key, params):
    items = list(params.items())
    items.sort()
    
    params_data = ""
    for key, value in items:
        params_data = params_data + str(key) + str(value)
    
    params_data = params_data + private_key
    
    '''use sha1 to encode keys'''
    hash_new = hashlib.sha1()
    hash_new.update(params_data.encode(encoding="utf-8"))
    hash_value = hash_new.hexdigest()
    return hash_value

你可能感兴趣的:(Ucloud 签名算法)