示例#1
0
 def authorized(self, user: str, password: str) -> bool:
     if isinstance(user, str) and isinstance(password, str) is False:
         print("Неверный тип данных!")
         return False
     if not os.path.exists(user):
         print('Неверные данные!')
         return False
     with open(os.path.abspath(user) + '/USER_INFO/password.txt',
               'r') as file:
         user_password = file.read()
     if Auto.Autorise().check_password(user_password, password):
         with open(os.path.abspath(user) + '/USER_INFO/enc_key.txt',
                   'rb') as byte_enc_key_file:
             self.__user_secret_key = byte_enc_key_file.read()
         return True
     else:
         print('Неверные данные!')
         return False
示例#2
0
    print('3-Обновить заметку')
    print('4-Удалить заметку')
    print('5-Количество заметок')
    print('6-Выход в меню управления аккаунтом')
    return None


db = Data.Data()
db.create_new_user_db()
os.chdir('DataBase')
sec = Security.Security()
auth_flag = False
secret_key = b''
while True:
    main_menu()
    main_menu_choice = Auto.Autorise().menu_choice()
    print()
    if main_menu_choice == 1:
        user = ''
        password = ''
        while True:
            user = Auto.Autorise().get_correct_str('логин')
            password = Auto.Autorise().get_password()
            if db.authorized(user, password):
                print('Авторизация прошла успешно')
                auth_flag = True
                master_key = sec.gen_master_key(password)
                secret_key = sec.decrypt(db.get_secret_key(), master_key)
            else:
                auth_flag = False
            if auth_flag: