python小程序-0017
来源:互联网 发布:mysql的存储过程 编辑:程序博客网 时间:2024/06/01 09:42
第17题:通常,登陆某个网站或者 APP,需要使用用户名和密码。密码是如何加密后存储起来的呢?请使用 Python 对密码加密。
- 阅读资料 用户密码的存储与 Python 示例
- 阅读资料 Hashing Strings with Python
- 阅读资料 Python’s safest method to store and retrieve passwords from a database
#!/usr/bin/env python3# -*- coding : utf-8 -*-from hashlib import sha256from hmac import HMACimport osdef encrypt_password(password,salt = None): if salt is None: salt = os.urandom(8) if isinstance(salt,str): salt = salt.encode('utf-8') new_password = password.encode('utf-8') encrypt_password = HMAC(salt,new_password,sha256).hexdigest() print("Encrypt passwrod is %s."% encrypt_password )if __name__ == '__main__': raw_password = input("Please input your password:") encrypt_password(raw_password)
阅读全文
0 0
- python小程序-0017
- python小程序
- python 小程序
- python小程序
- python 简单小程序
- python小程序集锦
- python爬虫小程序
- Python小程序
- python小程序
- python练习小程序
- Python入门小程序
- python 查询小程序
- [python] 小程序
- Python里小程序
- Python通讯录小程序
- Python小程序
- python界面小程序
- python小程序
- IOS程序生命周期
- SQLException: The server time zone value '�й���ʱ��' is unrecognized
- python 和 selenium实现web UI功能自动化测试框架(米兔888)
- 第四题 替换空格
- CentOS 默认防火墙设置
- python小程序-0017
- matplotlib基础——matplotlib.pyplot.scatter
- APP 缓存数据线程安全问题探讨
- POJ1556---The Doors (计算几何基础:判断线段相交(快速排斥实验+跨立实验))
- 白话经典算法系列之三 希尔排序的实现
- el表达式:获得web开发常用对象
- web自动化测试第5步:浏览器/页面信息的获取
- F
- java基础知识0719