private void signin_button_Click(object sender, RoutedEventArgs e) { AUtils t = new AUtils(); AEncrypter encrypter = new AEncrypter(); encrypter.ReadKeyFile(); AStatic.StringKey = key_textBox.Text; if (encrypter.ValidKey(AStatic.StringKey)) { if (encrypter.DecryptFile(AStatic.DbPath)) { AStatic.IsRunning = true; t.ReadCatalog(); NavigationService.Navigate(new Uri("AHome.xaml", UriKind.Relative)); } } else { signinlabel.Content = FindResource("StrUid_wrongkey").ToString(); } }
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"; } }
public void WaitingEncrypt() { System.Threading.Thread.Sleep(2000); if (File.Exists(AStatic.DbPath)) { while (true) { if (!IsFileInUse(AStatic.DbPath)) { AEncrypter encrypter = new AEncrypter(); encrypter.EncryptFile(AStatic.DbPath); AStatic.IsRunning = false; break; } } } }