zoukankan      html  css  js  c++  java
  • 一个认证的过程

    import ast
    import os
    import sys
    BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    #添加环境变量
    sys.path.insert(0,BASE_DIR)
    # print(BASE_DIR)
    #数据库目录
    Status = "%s测试confsettings" % BASE_DIR
    print(Status)
    
    ACCOUNT_FILE = "%s测试Infomyaccount" % BASE_DIR
    Status_FILE = "%s测试confsettings" %BASE_DIR
    # STATUS_CODE  = {
    #     250 : "Invalid cmd format, e.g: {'action':'get','filename':'test.py','size':344}",
    #     251 : "Invalid cmd ",
    #     252 : "Invalid auth data",
    #     253 : "Wrong username or password",
    #     254 : "Passed authentication",
    #     255 : "Filename doesn't provided",
    #     256 : "File doesn't exist on server",
    #     257 : "ready to send file",
    #     258 : "md5 verification"
    # }
    while True:
        def Auth():
            user_input = str(input("请输入您的账户:"))
            passwd_input = str(input("请输入您的密码:"))
            with open(ACCOUNT_FILE, "r", encoding="utf8") as read_file:
                data = ast.literal_eval(read_file.read())
                username = data["name"]
                passwd = data["password"]
                with open(Status_FILE,"r",encoding="utf8") as Status:
                    Status_data = ast.literal_eval(Status.read())
    
                if user_input == username and passwd_input == passwd:
                    # with open(Status,"r",encoding="utf8") as account_file:
                    #     Account_data = ast.literal_eval(account_file.read())
    
                        print(Status_data[254])
                else:
                        print(Status_data[253])
        Auth()
    

    目录格式为:

  • 相关阅读:
    Makefile学习
    Tmux使用
    Linux进程管理学习资料
    Linux内存管理学习资料
    Python常用的软件包
    Docker 学习
    Intel处理器技术文档
    Firefly-RK3399笔记
    Linux Kernel API
    ARM 技术文档
  • 原文地址:https://www.cnblogs.com/uglyliu/p/6150090.html
Copyright © 2011-2022 走看看