private void button1_Click(object sender, EventArgs e) { if (!validate_generate_key()) { MessageBox.Show("X and G must be less than p"); return; } // Generate Key Button SaveFileDialog fileBrowser = new SaveFileDialog(); if (fileBrowser.ShowDialog() == DialogResult.OK) { string fileName = fileBrowser.FileName; Key key = new Key((long)key_generate_p.Value, (long)key_generate_g.Value, (long)key_generate_x.Value); key.saveToFile(fileName); } }
private void saveKeysButton_Click(object sender, RoutedEventArgs e) { try { // Fetch ingredients for private key long p = Convert.ToInt64(pTextBox.Text); long g = Convert.ToInt64(gTextBox.Text); long x = Convert.ToInt64(xTextBox.Text); // Generate key Key k = new Key(p, g, x); ElGamalApplication.Key.PrivateKey pri = k.GeneratePrivateKey(); ElGamalApplication.Key.PublicKey pub = k.GeneratePublicKey(); SaveFileDialog fileBrowser = new SaveFileDialog(); Nullable<bool> result = fileBrowser.ShowDialog(); if (result == true) { string fileName = fileBrowser.FileName; k.saveToFile(fileName); } } catch (Exception ex) { ShowMessageBox("Key generation failed."); } }