内容来自debugtalk
import hashlib import random import string def gen_random_string(str_len):
'''生成指定长度的随机数函数''' return ''.join( random.choice(string.ascii_letters + string.digits) for _ in range(str_len)) def gen_md5(*args):
'''MD5加密''' return hashlib.md5("".join(args).encode('utf-8')).hexdigest() gen_random_string(5) # => A2dEx TOKEN = "debugtalk" data = '{"name": "user", "password": "123456"}' random = "A2dEx" print gen_md5(TOKEN, data, random)