python的hashlib库

import hashlib

password ='12f3456'
m = hashlib.md5(password.encode())
# m1=hashlib.sha1(password.encode()) #sha1加密方法
# m2=hashlib.sha224(password.encode())

print(password.encode())  #字符串encode变成二进制 b'123456',字符串只能转换成二进制的才能进行加密

print(dir(m)) #将m能用的方法全部展示.如果忘记了某个元素有什么方法,可以用dir()展示出来
''''


['__class__', '__delattr__', '__dir__', '__doc__', 
'__eq__', '__format__', '__ge__', '__getattribute__',
 '__gt__', '__hash__', '__init__', '__init_subclass__', 
 '__le__', '__lt__', '__ne__', '__new__', '__reduce__', 
 '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', 
 '__str__', '__subclasshook__', 'block_size', 'copy', 'digest', 
 'digest_size', 'hexdigest', 'name', 'update']



'''
print(m.hexdigest())  #将m进行加密


print(len(m.hexdigest()))  #不管密码多长,只能返回一个32的MD5加密的字符串。且MD5不可逆

 

转载于:https://www.cnblogs.com/miyatest/p/10124172.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值