import hashlib
def calc_md5(password):
hash=hashlib.md5()
hash.update(password.encode('utf-8'))
return hash
def login(user, password):
if user in db:
hash=calc_md5(password)
if hash.hexdigest()==db[user]:
return True
else:
return False
def login(username, password):
user = db[username]
password=password+user.salt
return user.password == get_md5(password)
Sign in to make a reply
永恒之约bo
import hashlib
def calc_md5(password):
hash=hashlib.md5()
hash.update(password.encode('utf-8'))
return hash
def login(user, password):
if user in db:
hash=calc_md5(password)
if hash.hexdigest()==db[user]:
return True
else:
return False
else:
return False
def login(username, password):
user = db[username]
password=password+user.salt
return user.password == get_md5(password)