Discuss / Python / 练习

练习

Topic source
import hashlib
db ={}

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

md5 = hashlib.md5()

def register(name,pw):
    db[name] = getMd5(name+pw+'the_Salt')

def login(name,pw):
    if db[name] == getMd5(name+pw+'the_Salt'):
        print("login success!")
    else:
        print("login failt!")

register('zh','123')
login('zh','123')

  • 1

Reply