hashlib模块 简单了解
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'\x9e\x8c\xd9\xccZ\x03\xdf\x96R\xa4\xa5am]\x82^\xd3T\x07E\x0e1 15 \x85\xbab@d\x0fJ,u\x05\x02\x14\x08*%\xf7}\xcc*\x0bY\xe8BK\x0e\xb2\xcb) 16 \xc9tm\x9f\xe3\x01\xa5\xad\x8c5ME\xa6}' 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'\xb8\x997}2\xd9\x99X|\xeb\x9c\xca\xb0E*[F\x94\xdb\x99'