首页 > 编程语言 > 详细

python_hashlib,md5,getpass, 密码加密,隐藏,加盐

时间:2019-06-19 14:52:20      阅读:130      评论:0      收藏:0      [点我收藏+]
# coding = utf-8
import hashlib
import getpass
LIST_01 = []


def registers():
print("请按提示创建用户信息")
while True:
print("(提示:输入用户名为 N/n时,退出输入)")
name = input("输入用户名")
if name.upper() == "N":
break
pwd = getpass.getpass("密码")
password = get_md5(pwd)
temp = {"user_name": name, "password": password}
LIST_01.append(temp)


def get_md5(data):
obj = hashlib.md5("wenxing".encode("utf-8"))
obj.update(data.encode("utf-8"))
password = obj.hexdigest()
return password


def login():
print("**********登录************")
user = input("用户名")
pwd = getpass.getpass("密码")

for item in LIST_01:
if item["user_name"] == user and item["password"] == get_md5(pwd):
return True


registers()
print(LIST_01)
result = login()
if result:
print("成功")
else:
print("失败")

python_hashlib,md5,getpass, 密码加密,隐藏,加盐

原文:https://www.cnblogs.com/lutos/p/11050740.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!