cryptographic module hashlib

import hashlib 
m=hashlib.md5()
#bytes must be of binary type
passwd='nhy123'
m.update(passwd.encode())#Cannot encrypt the string directly, first convert the string to bytes type
print(m .hexdigest())
# print(m.__doc__)#See what method
#md5 encryption is irreversible
def my_md5(str):
new_str=str.encode()#Convert the string to bytes type
# new_str=b'% s'%str# Convert the string to bytes type
m=hashlib.md5()#Instantiate the MD5 object
m.update(new_str)#Encrypt
return m.hexdigest()#Get the result and return

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324643014&siteId=291194637