encryption

import hashlib

m = hashlib.md5() # Instantiation 
# bytes 
passwd = ' NHY_*&^_1982343532 ' 
# passwd.encode() #Convert the string to bytes type 
m.update(passwd.encode()) #Cannot    directly match characters String encryption, first convert the string to bytes type 
print (m.hexdigest())
 # md5 encryption is irreversible

#撞库
# befor       after
   # nhy123  81fb61ce98e508df8dbe8da07ad9acfc

def my_md5(str):
    import hashlib
    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 )   #Encryption return m.hexdigest
     () #Get   the result and return

# hashlib.sha512

 

Guess you like

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