【发布时间】:2018-12-27 20:22:39
【问题描述】:
我目前在 Java 应用程序中使用 BouncyCastle PGP 从字符串中读取公钥,并使用该密钥加密文件。正在加载密钥...
Security.addProvider(new BouncyCastleProvider());
InputStream keyIn = new ByteArrayInputStream(publicKey.getBytes());
PGPPublicKeyRingCollection pgpKeyRing = new PGPPublicKeyRingCollection(PGPUtil.getDecoderStream(keyIn), new JcaKeyFingerpringCalculator());
PGPPublicKey = pgpKeyRing.getKeyRings().next().getPublicKey();
输出文件可以用
解密gpg --decrypt file.gpg
即使 gpg --list-keys 和 gpg --list-secret-keys 为空
这怎么可能?它是否可能从其他地方读取钥匙圈?我在 CentOS 7 上,我删除了 ~/.gnupg 并重新创建了它。
我还尝试更改用于加密的公钥,但它仍然可以解密。
【问题讨论】:
标签: java encryption bouncycastle gnupg pgp