1 import hashlib 2 '''不可逆加密''' 3 password = 'wwwwww7777'.encode('utf8') 4 word = hashlib.md5(password) # md5加密方式 5 print(word.hexdigest()) # ebc17a074a63e18c46c720be01b9b9d1 6 word1 = hashlib.sha512(password) 7 print(word1.hexdigest()) 8 ''' 9 9e8cd9cc5a03df9652a4a5616d5d825ed35407450e3185ba6240640f4a2c75050214082 10 a25f77dcc2a0b59e8424b0eb2cb29c9746d9fe301a5ad8c354d45a67d 11 ''' 12 print(word1.digest()) 13 ''' 14 b'x9ex8cxd9xccZx03xdfx96Rxa4xa5am]x82^xd3Tx07Ex0e1 15 x85xbab@dx0fJ,ux05x02x14x08*%xf7}xcc*x0bYxe8BKx0exb2xcb) 16 xc9tmx9fxe3x01xa5xadx8c5MExa6}' 17 ''' 18 19 20 # 加盐(密码用) 21 salt = 'vrvbgnyn'.encode('utf8') 22 password = 'wwwwfff'.encode('utf8') + salt 23 word3 = hashlib.pbkdf2_hmac('sha1', password, salt, 500) # 加密500次 24 print(word3) # b'xb8x997}2xd9x99X|xebx9cxcaxb0E*[Fx94xdbx99'