private void SaveKeys(object sender, RoutedEventArgs e) { try { // Fetch ingredients for private key BigInteger p = BigInteger.Parse(pTextBox.Text); BigInteger g = BigInteger.Parse(gTextBox.Text); BigInteger x = BigInteger.Parse(xTextBox.Text); // Generate key SiGamalEngine.Key k = new SiGamalEngine.Key(p, g, x); SiGamalEngine.Key.PrivateKey pri = k.GeneratePrivateKey(); SiGamalEngine.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(ex.Message); } }
private void GeneratePrivateKey(object sender, RoutedEventArgs e) { try { // Fetch ingredients for private key /*BigInteger p = BigInteger.Parse(pTextBox.Text); * BigInteger g = BigInteger.Parse(gTextBox.Text); * BigInteger x = BigInteger.Parse(xTextBox.Text);*/ // Generate key SiGamalEngine.Key k = SiGamalEngine.Key.GenerateRandomKey(); SiGamalEngine.Key.PrivateKey pri = k.GeneratePrivateKey(); SiGamalEngine.Key.PublicKey pub = k.GeneratePublicKey(); xTextBox.Text = pri.X.ToString(); yTextBox.Text = pub.Y.ToString(); pTextBox.Text = pub.P.ToString(); gTextBox.Text = pub.G.ToString(); } catch (Exception ex) { ShowMessageBox(ex.Message); } }
private void SaveKeySignButton_Click(object sender, EventArgs e) { // Save Key try { // Fetch ingredients for private key BigInteger p = BigInteger.Parse(pSignTextBox.Text); BigInteger g = BigInteger.Parse(gSignTextBox.Text); BigInteger x = BigInteger.Parse(xSignTextBox.Text); // Generate key Key k = new Key(p, g, x); Key.PrivateKey pri = k.GeneratePrivateKey(); Key.PublicKey pub = k.GeneratePublicKey(); SaveFileDialog fileBrowser = new SaveFileDialog(); DialogResult result = fileBrowser.ShowDialog(); if (result == DialogResult.OK) { string fileName = fileBrowser.FileName; k.saveToFile(fileName); } } catch (Exception ex) { //ShowMessageBox("Key generation failed."); } }
private void RandomKeySignButton_Click(object sender, EventArgs e) { // Generate Random Key key = Key.GenerateRandomKey(); Key.PrivateKey pKey = key.GeneratePrivateKey(); pSignTextBox.Text = pKey.P.ToString(); gSignTextBox.Text = pKey.G.ToString(); xSignTextBox.Text = pKey.X.ToString(); }
private void SaveKeys(object sender, RoutedEventArgs e) { try { // Fetch ingredients for private key BigInteger p = BigInteger.Parse(pTextBox.Text); BigInteger g = BigInteger.Parse(gTextBox.Text); BigInteger x = BigInteger.Parse(xTextBox.Text); // Generate key SiGamalEngine.Key k = new SiGamalEngine.Key(p, g, x); SiGamalEngine.Key.PrivateKey pri = k.GeneratePrivateKey(); SiGamalEngine.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(ex.Message); } }