Beispiel #1
0
    def start_process(self):
        path = self.target_path.get()
        selected_key = self.selected_key.get()
        key = self.saved_keys[selected_key]

        if selected_key not in self.allowed_keys:
            messagebox.showerror(
                title="Bad Request",
                message="Key is not allowed for this encryption direction")
            return

        encryption_helper = EncryptionHelper(key, path)
        try:
            if self.direction.get():
                encryption_helper.decrypt()
            else:
                encryption_helper.encrypt()

            self.target_path.delete(0, tk.END)
            messagebox.showinfo(title="Success", message="Process finished")
        except Exception as ex:
            messagebox.showerror(title="Process failed", message=ex)
Beispiel #2
0
            if (decrypted_message != message_scaled):
                secret_key = key_gen.generate_secret_key() # If the key is regenerated every iteration, the chances of a correct encryption/decryption rises
                count += 1
            elif (decrypted_message == message_scaled):
                print("The message {0} was recovered after {1} iterations out of 1000".format(decrypted_message/factor, count))
                break
            if(count > 1000):
                not_found_message()

        count = 0
        while True:
            encrypted_matrix_1 = MatrixEncryption().encrypt_message(secret_key, message_scaled)
            encrypted_matrix_2 = MatrixEncryption().encrypt_message(secret_key, message1_scaled)
            N_squared = EncryptionHelper.get_N_squared()
            encrypted_matrix_2 = EncryptionHelper().mod_quaternion_matrix(encrypted_matrix_2, N_squared)
            sum_matrix = np.add(encrypted_matrix_1, encrypted_matrix_2)
            decrypted_message = MatrixDecryption().decrypt_message(secret_key, sum_matrix, False)

            if (decrypted_message != (message_scaled + message1_scaled)):
                count += 1
            elif (decrypted_message == (message_scaled + message1_scaled)):
                print("The sum {0} was recovered after {1} iterations out of 1000".format(decrypted_message/factor, count))
                break
            if (count > 1000):
                not_found_message()

        is_not_found = False

    except:
        retries += 1