123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- # coding=utf-8
- # + + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + +
- # ┏┓ ┏┓+ +
- # ┏┛┻━━━┛┻┓ + +
- # ┃ ┃
- # ┃ ━ ┃ ++ + + +
- # ████━████ ┃+
- # ┃ ┃ +
- # ┃ ┻ ┃
- # ┃ ┃ + +
- # ┗━┓ ┏━┛
- # ┃ ┃
- # ┃ ┃ + + + +
- # ┃ ┃ Codes are far away from bugs with the animal protecting
- # ┃ ┃ + 神兽保佑,代码无bug
- # ┃ ┃
- # ┃ ┃ +
- # ┃ ┗━━━┓ + +
- # ┃ ┣┓
- # ┃ ┏┛
- # ┗┓┓┏━┳┓┏┛ + + + +
- # ┃┫┫ ┃┫┫
- # ┗┻┛ ┗┻┛+ + + +
- # + + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + +"""
- """
- """
- import base64
- import hashlib
- import time
- def md5(text, isBackByte=False):
- """md5加密函数"""
- md5 = hashlib.md5()
- if isinstance(text, bytes):
- md5.update(text)
- else:
- md5.update(text.encode('utf-8'))
- if isBackByte:
- # 返回二进制的加密结果
- return md5.digest()
- # 返回十六进制的机密结果
- return md5.hexdigest()
- def base64_encode(text, isBytes=False):
- """进行base64编码处理"""
- if isBytes:
- return base64.b64encode(text)
- return base64.b64encode(bytes(text, encoding="utf-8"))
- def get_timestamp10():
- """获取当前时间长度为10位长度的时间戳"""
- return int(time.time())
- url = 'http://192.168.136.45:8077'
- secret = 'ansjer'; # 密钥--对应#st的哈希格式为 secret+url+e,e为时间戳单位s,url为请求地址
- path = '/OTA/downloads/IPC/18E2012008A/4.1.5/V4.1.5.18E2012008A.img' # 下载文件
- # 下载到期时间,time是当前时间,300表示300秒,也就是说从现在到300秒之内文件不过期
- expire = get_timestamp10() + 3600;
- res = md5(str(secret) + str(path) + str(expire), True)
- md5 = str(base64_encode(res, True))
- md5 = md5.replace('b\'', '').replace('\'', '').replace('+', '-').replace('/', '_').replace('=', '')
- print(url+path+'?' + 'st=' + str(md5) + '&e=' + str(expire))
|