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 LoadPrivateKey(object sender, RoutedEventArgs e) { string fileKey = ShowOpenDialog("Private Key (*.pri)|*.pri"); if (fileKey == null) { return; } SiGamalEngine.Key.PrivateKey key = SiGamalEngine.Key.GeneratePrivateKeyFromFile(fileKey); signPTextBox.Text = key.P.ToString(); signGTextBox.Text = key.G.ToString(); signXTextBox.Text = key.X.ToString(); }