Python——md5加密應用—用戶登陸----密碼:md5加密


import hashlib

def get_md5():
    obj = hashlib.md5('iuqe832643873gh'.encode('utf-8'))
    obj.update(data.encode('utf-8'))
    result = obj.hexdigest()
    return result

USER_LIST = []

def enroll():
    print('************用戶注冊************')
    while True:
        user = input('請輸入用戶名:')
        if user == 'N':
            return
        pwd = input('請輸入密碼:')
        temp = {'username': user, 'password': get_md5(pwd)}
        USER_LIST.append(temp)

def login():
    print('************用戶登陸************')
    user = input('請輸入用戶名:')
    pwd = input('請輸入密碼')
    for obj in USER_LIST:
         if obj['username'] == user and obj['password'] == get_md5(pwd):
             return True

enroll()
result = login()
if result:
    print('登陸成功!')
else:
    print('登陸失敗!')

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM