python-模块加密hashlib

import hashlib
# md5
ybm_pwd='yuanbapqingsdfs234FF234HF@F' #
m = hashlib.md5() #
bytes_ybq = ybm_pwd.encode()#把字符串转成bytes类型
m.update(bytes_ybq) #加密,不能字符串,只能传bytes类型,二进制
print(m.hexdigest()) #加密后的结果
def md5_password(st:str):#限定了入参的类型,只能为string类型
bytes_st = st.encode() #转成二进制类型
m = hashlib.md5(bytes_st) #加密
return m.hexdigest() #返回加密后的结果


sha_256 =hashlib.sha256(bytes_ybq)
sha512 =hashlib.sha512(bytes_ybq)
print(sha512.hexdigest())

print(dir(m))

#md5加密是不可逆的,不能被解密的。
# MD5 md5AF
# 123456 f0dfb4c958c67903e542e31c729c629b

#撞库 网上解密都是撞库
原文地址:https://www.cnblogs.com/hoby2017/p/8298093.html