在与图书馆争夺一段时间后,我对如何从PgpPublicKey
对象获取这一简单数据感到茫然。我尝试过最明显的路由GetUserAttributes()
,但它返回一个空列表。 GetUserIds()
返回简单string
个对象的列表,但格式为"Your Name (comment)"
。
如何检索密钥ID的电子邮件地址?
答案 0 :(得分: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);
}
}
}
}