python学习 hashlib

 1 import hashlib #加密
 2 m=hashlib.md5()
 3 m.update('cherry'.encode('utf-8'))
 4 s=m.hexdigest()
 5 print(s)
 6 print(len(s))
 7 #打印结果 c7a4476fc64b75ead800da9ea2b7d072    32
 8 
 9 #运用于登录注册
10 import hashlib
11 import datetime
12 key_value='idcast'
13 now=datetime.datetime.now()
14 value=key_value+now.strftime('%y-%m-%d')
15 mm=hashlib.md5()
16 mm.update(value.encode('utf-8'))
17 print(mm.hexdigest())
18 #打印结果 a831c2e8747f3e03770e7ba4b7b2d6c1

 

posted on 2019-08-14 19:25  cherry_ning  阅读(134)  评论(0)    收藏  举报

导航