private void done_button_Click(object sender, RoutedEventArgs e) { AEncrypter encrypter = new AEncrypter(); if (encrypter.ValidKey(oldkey_textBox.Text)) { if (newkey_textBox.Text == confirm_textBox.Text) { AStatic.StringKey = newkey_textBox.Text; encrypter.WriteKeyFile(newkey_textBox.Text); encrypter.ReadKeyFile(); } else { tiptextblock.Text = FindResource("StrUid_newkeynotequal").ToString(); } } else { tiptextblock.Text = FindResource("StrUid_oldkeywrong").ToString(); } }
private void start_button_Click(object sender, RoutedEventArgs e) { // save dbpath to config.ini if (db_textBox.Text != "" && key_textBox.Text != "") { AUtils tool = new AUtils(); AEncrypter encrypter = new AEncrypter(); // 1 weite to config.ini tool.WriteConfig(db_textBox.Text); tool.ReadDbpath(); // 2 gen key file AStatic.StringKey = key_textBox.Text; encrypter.WriteKeyFile(key_textBox.Text); encrypter.ReadKeyFile(); // 3 create db Createdbtable(); DisableInit(); // 4 envrypt db encrypter.EncryptFile(AStatic.DbPath); Window m = Application.Current.Properties["mainwindow"] as Window; Frame main_frame = m.FindName("main_frame") as Frame; main_frame.Navigate(new ASignin()); } else if (db_textBox.Text == "") { db_textBox.Foreground = Brushes.Red; db_textBox.Text = "DB path can NOT be null"; } else if (key_textBox.Text == "") { key_textBox.Foreground = Brushes.Red; key_textBox.Text = "Key can NOT be null"; } }