import hashlib
import hmac
###加密模块
#hashilb :md5和SHA加密
x=hashlib.md5()
x.update('abc'.encode('utf8'))
print(x.hexdigest())
#abc===>900150983cd24fb0d6963f7d28e17f72
#单向的,无法abc<====900150983cd24fb0d6963f7d28e17f72
#可以破解,在线MD5查询
#MD5我们看到的场景:下载文件的时候:下载之前会有一个MD5码但凡下载后在本地电脑上被篡改了MD5会很大的不同。
#sha1__sha224(位数 )__sha384表示加密长度
#hmac:加密可以指定秘钥
#h=hmac.new('h'.encode(),'你好'.encode())
#result=h.hexdigest()
#print(result)
结果:
D:\pythonss\venv\Scripts\python.exe D:/pythonss/加密.py
900150983cd24fb0d6963f7d28e17f72
Process finished with exit code 0