Python hashlib模块 (主要记录md5加密)
来源:互联网 发布:怎么查看80端口被占用 编辑:程序博客网 时间:2024/04/29 23:25
python提供了一个进行hash加密的模块:hashlib
下面主要记录下其中的md5加密方式
>>> import hashlib >>> m = hashlib.md5() >>> m.update("Nobody inspects") >>> m.update(" the spammish repetition") #这里的update相当于把当前的字符串和上次的字符串连接在一起了,待加密的字符串为:Nobody inspects the spammish repetition>>> m.digest() '\xbbd\x9c\x83\xdd\x1e\xa5\xc9\xd9\xde\xc9\xa1\x8d\xf0\xff\xe9' >>> m.hexdigest() 'bb649c83dd1ea5c9d9dec9a18df0ffe9'
对以上代码的说明:
1.首先从python直接导入hashlib模块
2.调用hashlib里的md5()生成一个md5 hash对象
3.生成hash对象后,就可以用update方法对字符串进行md5加密的更新处理
4.继续调用update方法会在前面加密的基础上更新加密,相当于合并字符串
5.加密后的二进制结果
6.十六进制结果
0 0
- Python hashlib模块 (主要记录md5加密)
- Python hashlib模块 (主要记录md5加密)
- Python hashlib模块 (主要记录md5加密)
- python的加密模块 hashlib
- python学习之路(hashlib模块----加密)
- Python模块学习 ---- hashlib hash加密
- Python中hashlib模块, 快捷加密数据
- Python使用hashlib模块做字符串加密
- python的hashlib字符串加密模块
- python的hashlib字符串加密模块
- python md5 加密模块
- hashlib —— Python 的 md5 和 sha1 加密
- md5模块和hashlib模块
- python模块之hashlib: md5和sha算法
- python模块之hashlib: md5和sha算法
- python模块之hashlib: md5和sha算法
- Python hashlib模块
- python模块之hashlib
- MySql+webService cxf+json 简单框架
- 智能指针 shared_ptr 的使用方法
- 告别充电、直接更换电池,只是电动车的一场梦?
- 工业设计
- 01-用UML画顺序图
- Python hashlib模块 (主要记录md5加密)
- Installation error: INSTALL_PARSE_FAILED_NO_CER...
- python closure
- 设备号Major
- Hashtable的实现原理
- GridView事件标注
- 谢殿侠:尽在“掌”握:移动互联网时代的团队协作工具
- 在ListView中如何进行精确的定位
- Linux内核设计的艺术-进程间通信-信号