import time import datetime import hashlib def get_time_stamp13(): ''' 获取当前时间13位时间戳 :return: ''' # 生成13时间戳 eg:1540281250399895 datetime_now = datetime.datetime.now() # 10位,时间点相当于从UNIX TIME的纪元时间开始的当年时间编号 date_stamp = str(int(time.mktime(datetime_now.timetuple()))) # 3位,微秒 data_microsecond = str("%06d" % datetime_now.microsecond)[0:3] date_stamp = date_stamp + data_microsecond return int(date_stamp) secret_key='T2MYYolcWtYePZxEbBdeOBPUTamZttFy' def get_md5Key(now_time): ''' md加密 ,secret_key加密的盐值 :param now_time: 当前时间戳 :return: ''' now_time=str(now_time) md5 = hashlib.md5(secret_key.encode('utf-8')) md5.update(now_time.encode('utf-8')) return md5.hexdigest() if __name__ == '__main__': a = get_time_stamp13() print(get_md5Key(a))