Discuss / Python / 第一个

第一个

Topic source

洪哥传奇

#1 Created at ... [Delete] [Delete and Lock User]

import hashlib

def calc_md5(password):

    if isinstance(password,str):

        s = password.encode('utf-8')

    md5 = hashlib.md5()

    md5.update(s)

    return md5.hexdigest()

def login(user, password):

    if db.get(user,None) == calc_md5(password):

         return True

    return False


  • 1

Reply