hashlib 模块(加密模块)

用于给文档加密

 1 # Author:CallMeV
 2 # DATE  :2019-11-10
 3 # Time  : 18:24
 4 
 5 import hashlib
 6 
 7 m = hashlib.md5()
 8 print(m)
 9 
10 m.update('我喜欢你'.encode('utf8'))
11 print(m.hexdigest())  #81fbaa81762885ac3481fd4b416485e6
12 
13 m.update('高圆圆'.encode('utf8'))
14 print(m.hexdigest())  #1febe137d2ae456b448d758dd46d4d48
15 
16 m2 = hashlib.md5()
17 m2.update('我喜欢你高圆圆'.encode('utf8'))
18 print(m2.hexdigest()) #1febe137d2ae456b448d758dd46d4d48
19 
20 s = hashlib.sha256()
21 s.update('高圆圆我爱你'.encode('utf8'))
22 print(s.hexdigest()) #651ec0fe3a54345620351e819695bd1d3d340f3396dde5f13a2485a3f13289dd

 

猜你喜欢

转载自www.cnblogs.com/fly10086/p/11831270.html