Example #1
0
        public string GetSecretKey(ulong lKeyID, string strPassphrase)
        {
            TransportableSecretKey tskKey = skrKeyRing.Find(lKeyID);

            tskKey.PrimaryKey.GetDecryptedKeyMaterial(strPassphrase);

            byte[] bKey = tskKey.Generate();
            return(Armor.WrapPrivateKey(bKey));
        }
Example #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 {
         TransportableSecretKey tskKey = this.Find(KeyID);
         byte[] bKey   = tskKey.Generate();
         string strKey = Armor.WrapPrivateKey(bKey);
         swOutput.Write(strKey);
     } catch (Exception e) {
         throw new Exception("Error while trying to save a private key: " + e.Message);
     }
     swOutput.Close();
     bIsUpdated = false;
 }
Example #3
0
        public void Save(string strPath)
        {
            System.IO.StreamWriter swOutput = new StreamWriter(strPath);
            IEnumerator            ieKeys   = this.SecretKeys.GetEnumerator();

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