private void OnButtonSaveClicked(object _, RoutedEventArgs _2)
        {
            // Checks if the port couldn't be passed
            if (!int.TryParse(this.FieldPort.Text, out int port))
            {
                this.ShowError(Lang.config_save_port);
                return;
            }
            this.cfg.Port = port;

            try
            {
                // Tries to load the private key
                this.cfg.PrivateKey = SimpleSecurityUtils.LoadRSAFromJson(JObject.Parse(this.FieldRSA.Text));
            }
            catch
            {
                this.ShowError(Lang.config_save_key);
                return;
            }

            // Sets the host
            this.cfg.Host = this.FieldHost.Text;

            try
            {
                // Tries to save the config
                this.cfg.SaveConfig(PLCA.CONFIG_PATH, this.password);

                // Updates the main config
                PLCA.LOADED_CONFIG = this.cfg;

                // Closes the window
                this.Close();
            }
            catch (Exception ex)
            {
                // Shows the error
                this.ShowError(Lang.config_save_unknown, ex.Message);
            }
        }
        /// <summary>
        /// Loads the given config-file, decryptes it using the passed key and loads it as a config object
        /// </summary>
        /// <param name="filePath">The path to the configuration file.</param>
        /// <param name="key">The key to decrypt those bytes</param>
        /// <returns>The fully loaded config</returns>
        /// <exception cref="ConfigInvalidKeyException">If the given key couldn't decrypt the config</exception>
        /// <exception cref="ConfigCurruptedException">If the config seems to be currupted</exception>
        /// <exception cref="Exception">All exception that can be passed by File.ReadAllBytes using the filepath.</exception>
        public static Config LoadConfig(string filePath, string key)
        {
            // Reads the content of the passed config file
            byte[] rawData = File.ReadAllBytes(filePath);

            // Generates the actual key and iv from the previous plain text key
            byte[] aesKey = SimpleSecurityUtils.HashSHA256(Encoding.UTF8.GetBytes(key));
            byte[] aesIv  = SimpleSecurityUtils.HashMD5(Encoding.UTF8.GetBytes(key));

            // Tries to decrypt the config
            byte[] decrypted = SimpleSecurityUtils.DecryptAES(rawData, aesKey, aesIv);

            // Checks if the decryption failed
            if (decrypted == null)
            {
                throw new ConfigInvalidKeyException();
            }

            try
            {
                // The config that will be created
                Config cfg = new Config();

                // Tries to parse the config from json
                JObject json = JObject.Parse(Encoding.UTF8.GetString(decrypted));

                // Gets all values
                cfg.Port       = (int)json["port"];
                cfg.Host       = (string)json["host"] ?? string.Empty;
                cfg.PrivateKey = SimpleSecurityUtils.LoadRSAFromJson((JObject)json["rsa"]);

                // Returns the fully loaded config
                return(cfg);
            }
            catch
            {
                throw new ConfigCurruptedException(Encoding.UTF8.GetString(decrypted));
            }
        }