Article From:https://www.cnblogs.com/neilyoung22/p/9217220.html
 1 # Encryption module
 2 import  hashlib
 3 
 4 # md5 Encrypted MD5
 5 # 1.Initializing the MD5 module to generate MD5 objects
 6 # 2.Introducing the data to encrypt the data update
 7 # 3.Get the encrypted value hexdigest
 8 m = hashlib.md5()
 9 m.update('hello world'.encode('utf8'))  #python3 The default character encoding is Unicode
10 print(m.hexdigest())    #5eb63bbbe01eeed093cb22bb8f5acdc3
11 
12 # sha Encrypt the most sha256 calls
13 # 1.Initialize the sha256 object
14 # 2.Introducing the data to be encrypted
15 # 3.Get the encrypted value
16 m1 = hashlib.sha256()
17 m1.update("hello world".encode("utf8"))
18 print(m1.hexdigest())   #b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9

 

Leave a Reply

Your email address will not be published. Required fields are marked *