def setup_ui(self): self.setWindowTitle('Modern Cryptography') self.setMinimumSize(950, 600) self.central_widget = QtWidgets.QWidget(self) self.main_input = MainInput(self.central_widget) self.configuration_box = ConfigurationBox(self.central_widget) self.layout = QHBoxLayout() self.layout.addWidget(self.configuration_box) self.layout.addWidget(self.main_input) self.central_widget.setLayout(self.layout) self.setCentralWidget(self.central_widget) self.main_input.tab_string.input_mode.btn_execute.clicked.connect( self.execute_string) self.main_input.tab_file.input_mode.btn_execute.clicked.connect( self.execute_file) self.main_input.tab_string.output_string.btn_save_to_file.clicked.connect( self.save_to_file) self.main_input.tab_string.input_string.btn_load_from_file.clicked.connect( self.load_from_file) engine_type_signal = EncryptionParms.get_instance().signal.engine_type engine_type_slot = self.configuration_box.keygen.on_update_keygen_widget engine_type_slot_2 = self.configuration_box.key_setup.on_update_key_setup_widget engine_type_signal.connect(engine_type_slot) engine_type_signal.connect(engine_type_slot_2) self.configuration_box.keygen.btn_generate.clicked.connect( self.generate_key)
def __init__(self): super(MainWindow, self).__init__() self.enc_parms = EncryptionParms.get_instance() QThreadPool.globalInstance().setMaxThreadCount(cpu_count() - 1) self.setup_ui()
def browse_key(self, is_private: bool): filepath, _ = QFileDialog.getOpenFileName(self, 'Single File', QtCore.QDir.currentPath(), '*.pub *.pri') if filepath: key = EncryptionParms.get_instance().get_engine().load_key( filepath) self.apply_key(key, is_private)
def switch_mode(self): self.is_encrypt = not self.is_encrypt if self.is_encrypt: mode = ModeType.ENCRYPT else: mode = ModeType.DECRYPT EncryptionParms.get_instance().mode = mode self.lbl_mode_value.setText(mode.value)
def set_engine_type(self, idx: int): EncryptionParms.get_instance().update_engine_type( self.list_of_algorithm[idx])
def execute(self): EncryptionParms.get_instance().print_info()