24 lines
838 B
Python
24 lines
838 B
Python
import base64
|
|
import datetime
|
|
import hashlib
|
|
import time
|
|
import random
|
|
|
|
# 随机的token 随机数+随机时间+固定字符串
|
|
def createTempToken(): # 生成一个临时的Token
|
|
data = {
|
|
"t":time.time(),
|
|
"r":random.random(),
|
|
's':random.randint(0,99999),
|
|
'admin':'萌狼蓝天',
|
|
'QQ':'2952458479',
|
|
'email':'mllt9920@qq.com',
|
|
'type':'temp token'
|
|
''
|
|
}
|
|
pwd = hashlib.sha256((str(random.random())+"|"+str(datetime.date)+"|"+str(datetime.time)+"|"+str(random.random())+"|"+str(data)).encode('utf-8')).hexdigest()
|
|
result = str(base64.b64encode((str(data)+"&"+str(pwd)).encode('utf-8')),'utf-8')
|
|
return result
|
|
# 接收内容 将内容转为字符串后加密为base64
|
|
def createBase64(data):
|
|
return str(base64.b64encode(str(data).encode('utf-8')), 'utf-8') |