You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
1.1 KiB
29 lines
1.1 KiB
from hashlib import md5 |
|
|
|
|
|
class SignKey: |
|
@staticmethod |
|
def sign_dh(cinema_code, api_func, time_stamp): |
|
""" |
|
(1) 从json数据中获取如下参数: |
|
影院内码: cinemaCode (304) |
|
数据时间: timeStamp (20170103174201) |
|
接口函数: apiFunc (retailShelf) |
|
(2) 签名算法 Secret : r5e2t85tyu142u665698fzu |
|
签名: md5(md5(cinemaCode+apiFunc+timeStamp)+Secret) |
|
sign = md5(304retailShelf20170103174201) |
|
计算后得出: 562552d0070c680e33790d52484af8be |
|
sign = md5(562552d0070c680e33790d52484af8ber5e2t85tyu142u665698fzu) |
|
计算后得出: 9662bf3f96554976ddb4eeac8bbf2085 |
|
最终将字符串转换成大写得到 sign = 9662BF3F96554976DDB4EEAC8BBF2085; |
|
""" |
|
secret = 'r5e2t85tyu142u665698fzu' |
|
s_str = str(cinema_code) + str(api_func) + str(time_stamp) |
|
s_key = md5((md5(s_str.encode()).hexdigest() + secret).encode()).hexdigest().upper() |
|
return s_key |
|
|
|
|
|
if __name__ == '__main__': |
|
s = SignKey() |
|
# s.sign_dh(304, 20170103174201, 'retailShelf') |
|
print(s.sign_dh(304, 20210112161534, 'movieType')) |