17 lines
460 B
Python
17 lines
460 B
Python
import time
|
|
import uuid
|
|
import hashlib
|
|
def timeset():
|
|
# 获取当前时间戳
|
|
time_stamp = int(time.time())
|
|
# 获取随机数
|
|
nonce = str(uuid.uuid4())
|
|
# 应用密钥
|
|
app_secret = "8ff611f60e6e4413804379108b617f"
|
|
# 生成原始串
|
|
SIGN_TEMPLATE = "time:{},nonce:{},appSecret:{}".format(time_stamp, nonce, app_secret)
|
|
# 计算签名
|
|
sign = hashlib.md5(SIGN_TEMPLATE.encode()).hexdigest()
|
|
print("sign:", sign)
|
|
return time_stamp,nonce,sign
|