private void mi_genKeyPair_Click(object sender, RoutedEventArgs e) { SaveFileDialog fbd = new SaveFileDialog(); fbd.FileName = "publicKey.xml"; Nullable <bool> result = fbd.ShowDialog(); if (result == true) { Encipher.GenerateRSAKeyPair(out publicKey, out privateKey); using (StreamWriter sw = File.CreateText(fbd.FileName)) { sw.Write(publicKey); } } SaveFileDialog dlg = new SaveFileDialog(); dlg.FileName = "privateKey.xml"; Nullable <bool> resultTwo = dlg.ShowDialog(); if (result == true) { using (StreamWriter sw = File.CreateText(dlg.FileName)) { sw.Write(privateKey); } } }
private static void GenerateRSAKeyPair() { string publicKey = string.Empty; string privateKey = string.Empty; Encipher.GenerateRSAKeyPair(out publicKey, out privateKey); }