-
Notifications
You must be signed in to change notification settings - Fork 74
6214 Цветков А.А. Лаб.3 Вар.22 #266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
сделать clean up кода
ISB_LAB_3/gui/widgets.py
Outdated
| if self.filetypes: | ||
| if self.is_save: | ||
| path = filedialog.asksaveasfilename( | ||
| initialdir=initial_dir, | ||
| filetypes=self.filetypes, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
для выбора режима использовать match/case
ISB_LAB_3/gui/widgets.py
Outdated
| import tkinter as tk | ||
| from tkinter import filedialog | ||
| import ttkbootstrap as ttk | ||
| from ttkbootstrap.constants import PRIMARY, OUTLINE | ||
| from pathlib import Path | ||
| from typing import Tuple, Optional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не соответствует PEP
ISB_LAB_3/gui/styles.py
Outdated
| except Exception: | ||
| return None No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
вы ловите исключения и никак их не обрабатываете
ISB_LAB_3/gui/styles.py
Outdated
| # Конфигурация цветов | ||
| colors = { | ||
| "background": "#f0f0f0", | ||
| "accent": "#4a6ea9", | ||
| "text": "#333333", | ||
| "tab_background": "#d9d9d9", | ||
| "field_background": "white", | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
вынести в файл с настройками
ISB_LAB_3/gui/widgets.py
Outdated
| def _browse(self) -> None: | ||
| """Открывает диалоговое окно для выбора файла.""" | ||
| initial_dir = Path.home() | ||
| if self.path_var.get(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
у вас для этого целая функция есть
| import json | ||
| from pathlib import Path | ||
| from typing import Any, Optional | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не соответствует PEP
ISB_LAB_3/utils/init.py
Outdated
| from .file_io import read_file, write_file | ||
| from .config_manager import ConfigManager | ||
|
|
||
| __all__ = ['read_file', 'write_file', 'ConfigManager'] No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- зачем вы объявляете глобальную переменную?
- почему это исполняемый файл? в нем нет кода, только импорт библиотек
- подумайте еще раз
ISB_LAB_3/core/exceptions.py
Outdated
| class KeyGenerationError(CryptoError): | ||
| """Исключение при генерации ключей.""" | ||
|
|
||
|
|
||
| class EncryptionError(CryptoError): | ||
| """Исключение при шифровании данных.""" | ||
|
|
||
|
|
||
| class DecryptionError(CryptoError): | ||
| """Исключение при дешифровании данных.""" | ||
|
|
||
|
|
||
| class FileOperationError(CryptoError): | ||
| """Исключение при операциях с файлами (чтение/запись).""" No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
нет ни одного вызова для этих исключений
ISB_LAB_3/core/init.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
замечания аналогично ISB_LAB_3/utils/init.py
ISB_LAB_3/utils/init.py
Outdated
| from .config_manager import ConfigManager | ||
| from .file_io import read_file, write_file | ||
|
|
||
| __all__ = ["ConfigManager", "read_file", "write_file"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не исправлено
- зачем вы объявляете глобальную переменную?
- почему это исполняемый файл? в нем нет кода, только импорт библиотек
- подумайте еще раз
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не исправлено
| class KeyGenerationError(CryptoError): | ||
| """Исключение при генерации ключей.""" | ||
| pass | ||
|
|
||
|
|
||
| class EncryptionError(CryptoError): | ||
| """Исключение при шифровании данных.""" | ||
| pass | ||
|
|
||
|
|
||
| class DecryptionError(CryptoError): | ||
| """Исключение при дешифровании данных.""" | ||
| pass | ||
|
|
||
|
|
||
| class FileOperationError(CryptoError): | ||
| """Исключение при операциях с файлами (чтение/запись).""" | ||
| pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не исправлено
нет ни одного вызова для этих исключений
ISB_LAB_3/core/init.py
Outdated
| from .hybrid import generate_rsa_keys, hybrid_encrypt, hybrid_decrypt | ||
| from .exceptions import CryptoError | ||
|
|
||
| __all__ = [ | ||
| 'generate_rsa_keys', | ||
| 'hybrid_encrypt', | ||
| 'hybrid_decrypt', | ||
| 'CryptoError', | ||
| ] No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а зачем вам этот исполняемый модуль? что вы здесь делаете?
Проимпортировали библиотеки, нигде их не используете.
Создали глобальную переменную, которую тоже нигде не используете. И вообще зачем вам этот список переменных?
ISB_LAB_3/utils/config_manager.py
Outdated
| with open(self.config_path, "w", encoding="utf-8") as file: | ||
| json.dump(config, file, indent=4, ensure_ascii=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
добавьте обработку исключений
ISB_LAB_3/utils/init.py
Outdated
| from .config_manager import ConfigManager | ||
| from .file_io import read_file, write_file | ||
|
|
||
| __all__ = ["ConfigManager", "read_file", "write_file"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не исправлено
Daria-creator-lab
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
Точка входа:
app.py - точка входа в приложение. Запускает GUI.
Файл с зависимостями:
requirements.txt
Модули интерфейса:
Файл Описание
gui/main_window.py Основное окно приложения (логика интерфейса).
gui/styles.py Файл с настройкой стилей.
gui/widgets.py Файл с настройкой виджетов.
Модули шифрования:
Файл Описание
core/crypto.py Реализация RSA-AES: генерация ключей, шифрование/дешифрование.
core/exceptions.py Исключения для обработки ошибок крипто-операций.
core/init.py Модуль пакета core, создающий единую точку доступа к функциям и классам.
Вспомогательные утилиты:
Файл Описание
utils/file_io.py Безопасное чтение/запись бинарных и текстовых файлов.
utils/config_manager.py Управление настройками приложения (тема, пути к файлам).
utils/init.py Модуль пакета utils, создающий единую точку доступа к функциям и классам.
config/settings.json JSON-file с настройками.
config/init.py Модуль пакета config, cодержит константы путей для удобного импорта в других модулях.
Остальные файлы:
Ключи:
Ключ Описание
keys/private.pem Приватный RSA-ключ, предназначен для дешифровки симметричного AES-ключа, зашифрованного публичным (public.pem) ключом.
keys/public.pem Публичный RSA-ключ.
keys/encrypted_key.bin Зашифрованный AES-ключ.
Текстовые файлы:
Текст Описание
src/plain_text.txt Исходный текст
src/encrypted.bin Зашифрованный, при помощи public ключа, текст
src/decrypted.txt Расшифрованный, при помощи private ключа, текст