1 import hashlib 2 def my_md5(str): 3 bytes_pwd = str.encode() #Convert the string to bytes type 4 m = hashlib.md5()# Instantiate the md5 object to encrypt the string, you must first encrypt the string Convert to bytes type 5 m.update(bytes_pwd) #Encryption , cannot pass strings, only bytes type, binary 6 return m.hexdigest() #Get the result and return 7 print (my_md5( ' 12345455 ' ))
Its running code is as follows: