标签:hash utf8 span python process encode obj with enc
hashlib模块
1 import hashlib 2 3 m = hashlib.md5() 4 5 print(m) 6 7 m.update(‘hello world‘.encode(‘utf8‘)) 8 print(m.hexdigest()) 9 10 m.update(‘nizhipeng‘.encode(‘utf8‘)) 11 print(m.hexdigest()) 12 13 #上下结果一致 14 m1 = hashlib.md5() 15 m1.update(‘hello worldnizhipeng‘.encode(‘utf8‘)) 16 print(m1.hexdigest()) 17 18 19 s = hashlib.sha256() 20 s.update(‘hello world‘.encode(‘utf8‘)) 21 print(s.hexdigest()) #不可逆
加密。
执行结果:
<md5 HASH object @ 0x7f7df3887350>
5eb63bbbe01eeed093cb22bb8f5acdc3
71e9ccc2a9e17eea106f63ec7bacff5a
71e9ccc2a9e17eea106f63ec7bacff5a
b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9
Process finished with exit code 0
标签:hash utf8 span python process encode obj with enc
原文地址:https://www.cnblogs.com/112358nizhipeng/p/9565137.html