模块之Time,datatime,hashlib,hmac

time模块

打印三种不同格式的时间

time.time()  # 打印当前时间(秒)

time.sleep()  # 睡眠

datetime模块

修改时间

datetime.datetime.now() + datetime.timedelta(3)

hashlib模块

加密

m = hashlib.md5()
m.update(b'hello')
m.update(b'hello')
print(m.hexdigest())


m = hashlib.md5()
m.update(b'hellohello')
print(m.hexdigest())
  1. 结果永远都是相同长度的字符串
  2. 叠加性

hmac模块

加密, 加盐处理

m = hmac.new(b'123')
m.update(b'hellow')
print(m.hexdigest())
posted on 2019-09-12 20:37  十七zz  阅读(105)  评论(0编辑  收藏  举报