- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 RSACryptoServiceProvider 我已经生成了公钥和私钥。它生成的 key 格式如下:
公钥:
<RSAKeyValue>
<Modulus>m9bAoh2...eGNKYs=</Modulus>
<Exponent>AQAB</Exponent>
</RSAKeyValue>
私钥:
<RSAKeyValue>
<Modulus>m9bAo...ZAIeGNKYs=</Modulus>
<Exponent>AQAB</Exponent>
<P>xGj/UcXs...R1lmeVQ==</P>
<Q>yx6e18aP...GXzXIXw==</Q>
<DP>NyxvnJ...1xAsEyQ==</DP>
<DQ>La17Jycd...FhApEqwznQ==</DQ>
<InverseQ>JrG7WCT...Hp3OWA==</InverseQ>
<D>RdWsOFn....KL699Vh6HK0=</D>
</RSAKeyValue>
但是使用 PGP Desktop 我生成了这样的 key -
公钥:
mQCNBEoOlp8BBACi/3EvBZ83ZduvG6YHu5F0P7Z3xOnpIsaPvTk0q+dnjwDUa5sU
lEFbUZgDXSz7ZRhyiNqUOy+IG3ghPxpiKGBtldVpi33qaFCCEBiqsxRRpVCLgTUK
HP2kH5ysrlFWkxTo
=a4t9
私钥:
lQHgBEoOlp8BBACi/3EvBZ83ZduvG6YHu5F0P7Z3xOnpIsaPvTk0q+dnjwDUa5sU
lEFbUZgDXSz7ZRhyiNqUOy+IG3ghPxpiKGBtldVpi33qaFCCEBiqsxRRpVCLgTUK
waBnEitQti3XgUUEZnz/rnXcQVM0QFBe6H5x8fMDUw==
=CVPD
因此,当我传递由 PGP Desktop 生成的 key 时,它能够完美地进行加密和解密,但是当我传递由 RSACryptoServiceProvider 生成的 key 时,我无法加密和解密?
谁能告诉我如何在 PGP 生成的模式中生成 key ?
最佳答案
使用 bouncycaSTLe c# 库这就是我生成 key 对的方式。
public void GenerateKey(string username, string password, string keyStoreUrl)
{
IAsymmetricCipherKeyPairGenerator kpg = new RsaKeyPairGenerator();
kpg.Init(new RsaKeyGenerationParameters(BigInteger.ValueOf(0x13), new SecureRandom(), 1024, 8));
AsymmetricCipherKeyPair kp = kpg.GenerateKeyPair();
FileStream out1 = new FileInfo(string.Format("{0}secret.asc", keyStoreUrl)).OpenWrite();
FileStream out2 = new FileInfo(string.Format("{0}pub.asc", keyStoreUrl)).OpenWrite();
ExportKeyPair(out1, out2, kp.Public, kp.Private, username, password.ToCharArray(), true);
}
private static void ExportKeyPair(
Stream secretOut,
Stream publicOut,
AsymmetricKeyParameter publicKey,
AsymmetricKeyParameter privateKey,
string identity,
char[] passPhrase,
bool armor)
{
if (armor)
{
secretOut = new ArmoredOutputStream(secretOut);
}
PgpSecretKey secretKey = new PgpSecretKey(
PgpSignature.DefaultCertification,
PublicKeyAlgorithmTag.RsaGeneral,
publicKey,
privateKey,
DateTime.Now,
identity,
SymmetricKeyAlgorithmTag.Cast5,
passPhrase,
null,
null,
new SecureRandom()
// ,"BC"
);
secretKey.Encode(secretOut);
secretOut.Close();
if (armor)
{
publicOut = new ArmoredOutputStream(publicOut);
}
PgpPublicKey key = secretKey.PublicKey;
key.Encode(publicOut);
publicOut.Close();
}
并且它以装甲 ASCII 格式生成私钥和公钥,例如。
-----BEGIN PGP PUBLIC KEY BLOCK-----Version: BCPG v1.32mIsEShU7ywEEAKtxKTtGTyUaVxFuWBpziA2l7qDKhe6jznre3DMPuzDnN4Ax573a7s/bPOkzkK9tEUGFw+BW6F4DkKydv8SQfSN5Vvc0RFMha8X1E8jki1oXTIPA8bKKdg8ZewZt8+Zwpt5IPAkIydmxDhMjwd71ay3p1ypOfROFPOfc2dBPx/0JAAUTtAdoYW1zbWFuiJwEEAECAAYFAkoVdAsACgkQEz/ESPB1tojuIQP8CjAzJx8PoIN33pxQAfGF+fMCZx8/m7dDBE113aiio25BCvNKOpFwye2UK4ioKN70k24pzkyi8AZO22/su6GL7XEiiBZLPynBxJR4A7PzvD3KNqdQUqesu9IkPFyXz3UFH3clR0hnZtZtgnbkL9dvj5RYVuGiS3Dcf1zoLMOiCdc==dFfG-----END PGP PUBLIC KEY BLOCK-----
关于c# - 生成 pgp key 时出现问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/892249/
查看release notes Bounty CaSTLe 的版本,我没有看到任何日期或任何提及它符合 PGP 版本的内容。也许我的想法是错误的。 最佳答案 “PGP”代表产品和公司名称,是一个商标。
关闭。这个问题是off-topic .它目前不接受答案。 想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。 8年前关闭。 Improve this q
有没有办法转换(二进制).key文件到 ASCII 装甲 .asc文件? 之前有一篇帖子似乎暗示文件扩展名无关紧要,文件内容相同:What is the difference b/w .pkr and
我已使用 Bouncy Castle API 加密了一个文件。我已使用相同的 API 成功解密该文件。 但是我无法使用 PGP command line 解密该文件 没有显示错误消息,但未生成解密文件
我正在写一些 needs to do electronic signatures . 有些用户会像我一样是极客,并且已经拥有自己的 PGP key 。大多数人不会,也不想安装或维护它。 作为变通解决方
PGPKeyRingGenerator 构造函数采用密码短语来加密私钥。它用于执行此操作的算法是什么?它有一个名为 encAlgorithm 的字段,但我找不到任何解释这些算法是什么的文档。 最佳答案
我正在开发一个简单的 Java 代码,该代码使用 BouncyCaSTLe v1.51 打开 PGP 公钥并验证其中包含的签名。 目前,我能够加载公钥并迭代所有签名。但是,即使我使用与生成签名的私钥相
我正在使用 Bouncy CaSTLes 来压缩和加密一些数据。压缩方法因空引用异常而失败。以下方法执行压缩: private byte[] Compress(byte[] data)
我真的很苦恼,我需要在 C# 中使用 BouncyCaSTLe 加密和解密字符串。我确实确实尝试过自己做这件事。我确实设法创建了自己的 key (私钥和公钥)。 请记住,我刚从大学毕业。 最佳答案 我
我有一个应用程序使用 gpg key 并提示输入密码才能读取它。这是我这样做的方式(基于我在其他地方找到的示例: func Decrypt(publicKeyring string, secretKe
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 关闭 9 年前。 Improve this
我想在脚本中将 PGP 公钥导入我的钥匙串(keychain),但我不希望它将内容写入文件。现在我的脚本是这样做的: curl http://example.com/pgp-public-key -o
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题? Update the question所以它是on-topic对于堆栈溢出。 8年前关闭。 Improve this que
我需要检查文件是否是有效的 pgp 加密文件。我们得到的一些 pgp 文件具有 pgp 的扩展名,而有些则没有。我需要检查哪些文件是 pgp 加密文件,哪些不是。请让我知道是否有办法告诉。 最佳答案
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题? Update the question所以它是on-topic对于堆栈溢出。 8年前关闭。 Improve this que
修订控制 PGP 加密文本文件的好方法是什么? 目标是 仅将 PGP 加密(最好使用 ASCII 装甲)文本文件存储在本地存储库(工作副本)和远程存储库(逻辑上的“中央”存储库)中。 在存储修订历史记
我正在尝试使用 BouncyCaSTLe 来调试和扩展现有的 Java 代码,以解密和验证安全附件。 我已经查看了 BouncyCaSTLe 示例,但从中提取 PGP 安全附件的模型比较困难。从代码和
已关闭。这个问题是 off-topic 。目前不接受答案。 想要改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 已关闭10 年前。 Improve th
有谁知道Java中的充气城堡中的以下命令(GnuPG 2.17.2)相当于什么? gpg -e -r "recipient" --output output.gpg input.zip 最佳答案 创建
我正在使用公钥使用 openpgp 创建我的 java 产品的许可证。产品附带私钥,用于读取许可证文件。这是正确的方法吗?私钥可以用来生成公钥吗? 谢谢 最佳答案 没有。私钥应保密。 使用签名机制。使
我是一名优秀的程序员,十分优秀!