private void Import_Click(object sender, RoutedEventArgs e) { if (!ImportExportCheck()) { return; } // kill chrome if it's running if (Process.GetProcessesByName(browser.ProcessName).Length > 0) { MessageBox.Show($"{browser.ProcessName} is running. Please close it first", "Error"); return; } // initialize AES var crypto = new AesCrypto(browser.LocalState); string backupFile; List <Item> items = new List <Item>(); int count = 0; switch (dbType) { case "cookies": backupFile = String.Format("{0}_{1}.bak", Path.GetFileName(browser.CookieFile), DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss")); File.Copy(browser.CookieFile, backupFile, true); items = ExportCookies(); // re-encrypt all items foreach (Cookie c in items) { c.encrypted_value = crypto.Encrypt(c.decrypted_value); } count = items.Count(); ImportCookies(items); break; case "logins": backupFile = String.Format("{0}_{1}.bak", Path.GetFileName(browser.LoginFile), DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss")); File.Copy(browser.LoginFile, backupFile, true); items = ExportLogins(); // re-encrypt all items foreach (Login i in items) { i.password_value = crypto.Encrypt(i.decrypted_password_value); } count = items.Count(); ImportLogins(items); break; default: return; } MessageBox.Show($"Imported {count} {dbType}!"); }
private void Import_Click(object sender, RoutedEventArgs e) { if (!ImportExportCheck()) { return; } // kill chrome if it's running if (Process.GetProcessesByName(browser.processName).Length > 0) { MessageBox.Show($"{browser.processName} is running. Please close it first", "Error"); return; } // initialize AES var crypto = new AesCrypto(browser.localState); string backupFile = String.Format("Cookies_{0}.bak", DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss")); File.Copy(browser.cookieFile, backupFile, true); List <Cookie> items = ExportItems(); // re-encrypt all items foreach (Cookie c in items) { c.encrypted_value = crypto.Encrypt(c.decrypted_value); } ImportItems(items); MessageBox.Show("Imported!"); }