def _get_key(self) -> Key:
     key_read = None
     while not key_read:
         try:
             key_file = input("Enter the path to the key file: ")
             if not os.path.isfile(key_file):
                 raise FileNotFoundError(f"Could not find file {key_file}")
             key_read = Key.import_key(key_file)
         except Exception as ex:
             print(ex, file=sys.stderr)
     return key_read
    def decrypt(self, key: dict, image: dict):
        image_file = "ImageToDecrypt.png"
        output_image_file = "DecryptedImage.png"
        key_file = "DownloadedKey.key"

        image = image[list(image.keys())[0]]["content"]
        with open(image_file, "wb") as f:
            f.write(image)

        key = key[list(key.keys())[0]]["content"]
        with open(key_file, "wb") as f:
            f.write(key)

        decrypted_message, decrypted_image = decrypt(image_file, Key.import_key(key_file), self.cipher)
        cv2.imwrite(output_image_file, decrypted_image)

        if self.decrypted_text_widget is None:
            self.add_decryption_output(decrypted_message, output_image_file)
        else:
            self.decrypted_text_widget.value = decrypted_message