Python hashlib模块
2016-06-03 15:28
555 查看
import datetime KEY_VALUE = '/BeginMan/' now = datetime.datetime.now() m = hashlib.md5() str = '%s%s' %(KEY_VALUE,now.strftime("%Y%m%d")) print (m) m.update(str.encode('utf-8')) value = m.hexdigest() print (value)
应用场景:注册、登录、文件上传、相册加密....
hash.update(arg)
更新哈希对象以字符串参数,如果同一个hash对象重复调用该方法,则m.update(a); m.update(b) is equivalent to m.update(a+b).
hash.digest()
返回摘要,作为二进制数据字符串值,
hash.hexdigest()
返回摘要,作为十六进制数据字符串值,
hash.copy()
相关文章推荐
- python 数字类型变量及其方法详解
- Python变量详解
- python 全局变量global
- [python] python扫描网段IP
- Python Looping enumerate, reversed, sorted, iteritems, zip
- 如何调用已经写好的Python脚本
- Python:循环语句
- Python 标准日期格式
- python——python manage.py runserver执行错误
- Python datetime.datetime.isoweekday和date.weekday()
- python 验证码识别改进版
- 如何利用python中的langid,对文本语种进行分类
- python: android批量多渠道打包
- selenium python unittest 运行报错 Ran 3 tests in 0.000s OK
- 27. Remove Element [easy] (Python)
- python 学习笔记十八 django深入学习三 分页,自定义标签,权限机制
- python os模块功能和方法总结
- python3 MySQL 查询返回字典类型
- python中的map
- Python后端【闻宇】