import hashlib #练习1 def calc_md5(password): md5 = hashlib.md5() md5.update(password.encode('utf-8')) return md5.hexdigest() def login(user, password): return db[user] == calc_md5(password) #练习2 db = {} def get_md5(password): md5 = hashlib.md5() md5.update(password.encode('utf-8')) return md5.hexdigest() def register(username, password): db[username] = get_md5(password + username + 'the_Salt') def login(username, password): return db[username] == get_md5( password + username + 'the_Salt')
Sign in to make a reply
siusuu