public IList<GnuKey> GetKeysForEncryption() { var crypto = new PgpCrypto(new CryptoContext()); List<GnuKey> keys = new List<GnuKey>(); foreach (string key in crypto.GetPublicKeyUserIdsForEncryption()) { var match = Regex.Match(key, @"<(.*)>"); if (!match.Success) continue; GnuKey k = new GnuKey(); k.Key = match.Groups[1].Value; k.KeyDisplay = key; keys.Add(k); } return keys; }
public IList<KeyItem> GetKeysForEncryption() { var crypto = new PgpCrypto(new CryptoContext()); var keys = new List<KeyItem>(); foreach (PgpPublicKey key in crypto.GetPublicKeyUserIdsForEncryption()) { foreach (string user in key.GetUserIds()) { var match = Regex.Match(user, @"<(.*)>"); if (!match.Success) continue; var k = new KeyItem(); k.Key = match.Groups[1].Value; k.KeyDisplay = user; var fingerprint = key.GetFingerprint(); k.KeyId = fingerprint[fingerprint.Length - 4].ToString("X2") + fingerprint[fingerprint.Length - 3].ToString("X2") + fingerprint[fingerprint.Length - 2].ToString("X2") + fingerprint[fingerprint.Length - 1].ToString("X2"); if (key.GetValidSeconds() != 0) k.Expiry = key.CreationTime.AddSeconds(key.GetValidSeconds()).ToShortDateString(); keys.Add(k); } } return keys; }