1

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

4

1 回答 1

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);
于 2011-05-27T06:54:18.637 回答