class User:
def __init__(self, username, email, date_of_birth, password):
self.username = username
self.email = email
self.date_of_birth = date_of_birth
self.password = password
@staticmethod
def login_or_register():
userinput = input("login or register")
def register(self):
pass
def login(self, login_reg):
self.login_reg = login_reg
How do i make a user profile so that i will input the name, mail etc. and then it saves so i can login
heres a really simple way to do it:
import hashlib
db = {}
hash = lambda x: hashlib.md5(x.encode()).hexdigest()
def register(user, password, mail):
db[user] = {"password": hash(password), "mail": mail}
def login(user, password):
if db[user]["password"] == hash(password):
print("success!")
else:
print("fail")
register("ironkey", "password123", "example@example.com")
login("ironkey", "password")
login("ironkey", "password123")
# get credentials for the user ironkey
print(db["ironkey"])
fail
success!
{'password': '482c811da5d5b4bc6d497ffa98491e38', 'mail': 'example@example.com'}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.