2

在与图书馆斗争了一段时间后,我不知道如何从PgpPublicKey对象中获取这个简单的数据。我尝试了最明显的路线,GetUserAttributes()但它返回一个空列表。GetUserIds()返回简单string对象的列表,但格式为"Your Name (comment)".

如何检索密钥 ID 的电子邮件地址?

4

1 回答 1

2
public static void Test_ReadPublicKeys(PgpPublicKeyRingBundle publicKeyRingBundle)
{
    foreach (PgpPublicKeyRing publicKeyRing in publicKeyRingBundle.GetKeyRings())
    {
        foreach (PgpPublicKey publicKey in publicKeyRing.GetPublicKeys())
        {
            foreach (object userId in publicKey.GetUserIds())
            {
                //Prints "My_Key_Name (Notes) <my_email@gmail.com>"
                Console.WriteLine(userId); 
            }
        }
    }
}
于 2014-06-03T11:00:13.397 回答