import hashlib def get_md5(s): md5 = hashlib.md5() md5.update(s.encode('utf-8')) return md5.hexdigest() db = {} def register(username, password): db[username] = get_md5(password + username + 'the-Salt') def login(username, password): password_md5 = get_md5(password + username + 'the-Salt') return username in db and db[username] == password_md5 register('michael', '123456') print(login('michael', '123456'))
Sign in to make a reply
南墙小生