public static bool SaveDatabaseConfig() { string Value = Program.DatabaseServer + ";" + Program.DatabaseUsername + ";" + Program.DatabasePassword; // MessageBox.Show("Save: " + Value); byte[] bytes = Encoding.Default.GetBytes(Value); Cryptor.Encrypt(ref bytes); File.WriteAllBytes(DatabaseDirection, bytes); return(true); }
public static bool LoadDatabaseConfig() { if (File.Exists(DatabaseDirection) == false) { SaveDatabaseConfig(); // MessageBox.Show("New"); } else { byte[] bytes = File.ReadAllBytes(DatabaseDirection); Cryptor.Decrypt(ref bytes); string[] Value = System.Text.ASCIIEncoding.ASCII.GetString(bytes).Split(';'); // MessageBox.Show("bytes: " + bytes); // MessageBox.Show("old: " + Program.DatabaseServer + ","+ Program.DatabaseUsername + "," + Program.DatabasePassword + Environment.NewLine + Value[0] + Environment.NewLine + Value[1] + Environment.NewLine + Value[2]); Program.DatabaseServer = Value[0]; Program.DatabaseUsername = Value[1]; Program.DatabasePassword = Value[2]; } return(true); }