import hashlib
def md5(data_string):
obj = hashlib.md5()
obj.update(pwd.encode('utf-8'))
return obj.hexdigest() #密文
line = f'{user},{encrypt}\n'
#实现用户注册,密码加密
user = input('输入用户:')
pwd = input('输入密码')
with open ('db.txt','a',encoding='utf-8')as f:
f.write(line)
def md5(data_string):
obj = hashlib.md5()
obj.update(data_string.encode('utf-8'))
return obj.hexdigest() # 密文
# 实现用户注册,密码加密
user = input('输入用户:')
pwd = input('输入密码')
encrypt = md5(pwd)
line = f'{user},{encrypt}\n'
with open('db.txt', 'a', encoding='utf-8') as f:
f.write(line)