Discuss / Python / 第一题

第一题

Topic source

import hashlib

db={}

def calc_md5(name,password): md5=hashlib.md5() if name not in db: md5.update(password.encode('utf-8')) db[name]=md5.hexdigest() print(db) else: md5.update(password.encode('utf-8')) print(md5.hexdigest()) if md5.hexdigest()==db[name]: print('yes') else: print('no')

calc_md5('gk','123') calc_md5('hsq','123') calc_md5('gk','1234') calc_md5('hsq','123')


  • 1

Reply