第二题
import hashlib db = { 'michael': 'e10adc3949ba59abbe56e057f20f883e', 'bob': '878ef96e86145580c38c87f0410ad153', 'alice': '99b1c2188db85afee403b1536010c2c9' } def register(username,password): db[username]=get_md5(password+username+'the-Salt') def get_md5(password): a=hashlib.md5() a.update(password.encode('utf-8')) return a.hexdigest() def login(username,password): return db[username]==get_md5(password+username+'the-Salt') register('root','root') if login('root','root'): print('登录成功!') else: print('登录失败!')
Sign in to make a reply
儒生脱尘
第二题