python加密模块学习
2013-09-11 11:15
375 查看
1.md5模块
md5.new([arg])返回一个md5对象,如果给出参数,则相当于调用了update(arg)
md5.update(arg)用string参数arg更新md5对象
md5.digest()返回16字节的摘要,由传给update的string生成,摘要没有ascii字符
md5.hexdigest()以16进制的形式返回摘要
2.sha模块
用法同md5一样
3.crypt
crypt模块中就一个函数,crypt(str,salt)-->string
md5.new([arg])返回一个md5对象,如果给出参数,则相当于调用了update(arg)
md5.update(arg)用string参数arg更新md5对象
md5.digest()返回16字节的摘要,由传给update的string生成,摘要没有ascii字符
md5.hexdigest()以16进制的形式返回摘要
importmd5
a=md5.new('passwd') a.digest() 'v\xa2\x17;\xe692T\xe7/\xfaMm\xf1\x03\n' a.hexdigest() '76a2173be6393254e72ffa4d6df1030a' a.update('helloworld') a.digest() '\xb2\x83f\xb8\x14\xc9\xc6\x19k\x01\xfe\xd8\xd9\x8f\xe0H' a.hexdigest() 'b28366b814c9c6196b01fed8d98fe048'
2.sha模块
用法同md5一样
importsha
b=sha.new('passwd')
b.digest()
"0'LG\x90;\xd1\xba\xc7c;\xbf\tt1I\xeb\xab\x80_"
b.hexdigest()
'30274c47903bd1bac7633bbf09743149ebab805f'
b.update('hello')
b.digest()
'c\xc19\xb4]YGz\x85\xe8C\x8fF\xfe\x9e\xc3|\xb16\xba'
b.hexdigest()
'63c139b45d59477a85e8438f46fe9ec37cb136ba
3.crypt
crypt模块中就一个函数,crypt(str,salt)-->string
fromcryptimportcrypt
crypt('passwd','a')
'aaIslqfNH03LA'
crypt('passwd','abc')
'ab8RogIKnX0og'
crypt('passwd','a')
'aaIslqfNH03LA'
相关文章推荐
- python的加密模块(md5,sha,crypt)学习
- python模块学习-----加密、随机数生成
- python的加密模块(md5,sha,crypt)学习
- Python模块学习 ---- hashlib hash加密
- python的加密模块(md5,sha,crypt)学习
- Arduino 各种模块篇 [留个小任务,现在去学习python 网络编程]
- python 学习笔记day02-python循环、文件、函数、模块
- Python语言学习之一:环境搭建,执行方式及主模块和非主模块
- python自动化运维学习笔记一 psutil模块
- python 的日志logging模块学习
- [Python模块学习]chardet模块识别字节包编码
- Python模块学习 ---- httplib HTTP协议客户端实现
- python学习笔记(四)模块
- python学习笔记之—— calendar(日历)模块
- Python模块学习之logging日志封装
- Python urllib模块学习
- python模块学习之locust性能测试
- Python 模块【基础学习】
- python 入门学习---模块导入三种方式及中文注释
- python之web模块学习-- httplib