python-hashlib加密模块

1 import hashlib
2 def my_md5(str):
3     bytes_pwd = str.encode()#把字符串转成bytes类型
4     m = hashlib.md5()#实例化md5对象接对字符串加密,要先把字符串转成bytes类型
5     m.update(bytes_pwd)#加密,不能传字符串,只能传bytes类型,二进制
6     return m.hexdigest()#获取结果返回
7 print(my_md5('12345455'))

其运行代码如下:

人生的旅途,前途很远,也很暗。然而不要怕,不怕的人的面前才有路。
原文地址:https://www.cnblogs.com/ymany/p/8985099.html