Discuss / Python / 作业

作业

Topic source

import hashlib db = {}

def register(username, password): db[username] = get_md5(password + username + 'the-Salt')

def get_md5(s): md5 = hashlib.md5() md5.update(s.encode('utf-8')) return md5.hexdigest()

def login(username,password): return db[username] == get_md5(password+username+'the-Salt')

register('a','1') print(login('a','1')) print(login('a','2'))


  • 1

Reply