Beispiel #1
0
        public string GetPublicKey(ulong lKeyID)
        {
            TransportablePublicKey tpkKey = pkrKeyRing.Find(lKeyID, true);

            byte[] bKey = tpkKey.Generate();
            return(Armor.WrapPublicKey(bKey));
        }
Beispiel #2
0
 /// <summary>
 /// Saves a key to a location
 /// </summary>
 /// <param name="strPath">file path</param>
 /// <param name="KeyID">key to save</param>
 public void Save(string strPath, ulong KeyID)
 {
     System.IO.StreamWriter swOutput = new StreamWriter(strPath);
     try     {
         TransportablePublicKey tpkKey = this.Find(KeyID, false);
         byte[] bKey   = tpkKey.Generate();
         string strKey = Armor.WrapPublicKey(bKey);
         swOutput.Write(strKey);
     } catch (Exception e) {
         throw new Exception("Error while trying to save a public key: " + e.Message);
     }
     swOutput.Close();
     this.bIsUpdated = false;
 }
        public void Save(string strPath)
        {
            System.IO.StreamWriter swOutput = new StreamWriter(strPath);
            IEnumerator            ieKeys   = this.PublicKeys.GetEnumerator();

            while (ieKeys.MoveNext())
            {
                if (ieKeys.Current is TransportablePublicKey)
                {
                    try {
                        TransportablePublicKey tpkKey = (TransportablePublicKey)ieKeys.Current;
                        byte[] bKey   = tpkKey.Generate();
                        string strKey = Armor.WrapPublicKey(bKey);
                        swOutput.Write(strKey);
                    } catch (Exception e) {
                        MessageBox.Show("Error while trying to save a public key: " + e.Message, "Error...", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
            swOutput.Close();
            this.bIsUpdated = false;
        }