字典排序之后md5
import time
import hashlib
import requests
def hash_md5():
params ={
"past_num":"20",
# "banner_log":"",
"tab_id":"116",
"smzdm_id":"0",
"refresh":"0",
"tab_feed_style_type":"1",
"time_sort":t,
"tab_name":"数码",
"page":"1",
"limit":"20",
"v":"10.1.10",
"f":"android",
"sign":"A3556B536A5FC69B077770B2B6AB0
"time":t1+"000",
"weixin":"0",
}
key = "apr1$AwP!wRRT$gJ/q.X24poeBInlUJC"
# new_s = ''.join(['{}={}&'.format(k, v) for k, v in param.items()])
data_sorted = sorted(param.items(), key=lambda d: d[0])
new_s = ''.join(['{}={}&'.format(k, v) for k, v in data_sorted])
new_s = new_s + "key=" + key
print(new_s)
hash = hashlib.md5()
hash.update(new_s.encode(encoding='utf-8'))
return hash.hexdigest()
if __name__ == '__main__':
hash_md5()