繁体   English   中英

从 Bouncy Castle PGP 密钥读取电子邮件地址

[英]Reading an email address from a Bouncy Castle PGP key

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

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

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); 
            }
        }
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM