【问题标题】:Extracting Modulus and Exponent from PGP Public Key从 PGP 公钥中提取模数和指数
【发布时间】:2011-08-31 20:35:29
【问题描述】:

我正在开发一个实现 PGP 加密的应用程序。我面临一个问题,我们需要从 PGP 公钥中提取模数和指数。我正在使用Bouncy castle PGP 库。请帮忙。

【问题讨论】:

    标签: c# .net bouncycastle pgp openpgp


    【解决方案1】:

    选择公钥后试一下密码

     PgpPublicKey  PublicKey;
     var val = (RsaKeyParameters)PublicKey.GetKey();
     string ModulusVal = Convert.ToBase64String(Encoding.UTF8.GetBytes(val.Modulus.ToString()));
     string ExponentVal = Convert.ToBase64String(Encoding.UTF8.GetBytes(val.Exponent.ToString()));
    XDocument X = new XDocument(new XDeclaration("1.0", "UTF-8", "yes"),
                                            new XElement("RSAKeyValue",
                                                new XElement("Modulus", ModulusVal),
                                                new XElement("Exponent", ExponentVal)));
    X.Save(XMLFileSavePath, SaveOptions.None);
    

    【讨论】:

    • 我忘了提到我使用的是包含嵌入式 PGP 密钥的 X509 证书。你能提供一下代码吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-13
    • 2016-06-26
    • 2023-03-21
    • 2018-03-16
    • 2012-05-31
    • 2018-06-10
    相关资源
    最近更新 更多