I would like to use BouncyCastle to decrypt a GPG file from Java. All the examples that I found need a passphrase, but that is not applicable in our use case. The file can be decrypted from the command prompt with this command:
我想使用BouncyCastle从Java解密GPG文件。我发现的所有示例都需要密码,但这不适用于我们的用例。可以使用以下命令从命令提示符解密该文件:
gpg --output test.csv.zip --decrypt test.csv.zip.gpg
This works after using gpg --import
for both the public and private key.
这对公钥和私钥使用gpg --import后起作用。
How could I do this using BouncyCastle? Do I need the public key at all, as I guess I only need the private key for decrypting?
我怎么能用BouncyCastle做到这一点?我是否需要公钥,因为我想我只需要私钥进行解密?
1 个解决方案
#1
0
According to this (hopefully not outdated) example, you should be able to do this.
根据这个(希望没有过时)的例子,你应该能够做到这一点。
RSADecryption rsaDecryption = new RSADecryption();
privateKeyFilename = args[0].trim();
encryptedData = args[1].trim();
rsaDecryption.decrypt(privateKeyFilename, encryptedData);
That example expects you to pass two arguments; the first one would be the private key file name; and then the encrypted data as string. Probably not exactly what you are looking for, but good enough to get you going.
这个例子希望你传递两个参数;第一个是私钥文件名;然后将加密数据作为字符串。可能不完全是你想要的,但足以让你前进。
And if that doesn't do, you could look into the more sophisticated examples given here.
如果不这样做,你可以查看这里给出的更复杂的例子。
#1
0
According to this (hopefully not outdated) example, you should be able to do this.
根据这个(希望没有过时)的例子,你应该能够做到这一点。
RSADecryption rsaDecryption = new RSADecryption();
privateKeyFilename = args[0].trim();
encryptedData = args[1].trim();
rsaDecryption.decrypt(privateKeyFilename, encryptedData);
That example expects you to pass two arguments; the first one would be the private key file name; and then the encrypted data as string. Probably not exactly what you are looking for, but good enough to get you going.
这个例子希望你传递两个参数;第一个是私钥文件名;然后将加密数据作为字符串。可能不完全是你想要的,但足以让你前进。
And if that doesn't do, you could look into the more sophisticated examples given here.
如果不这样做,你可以查看这里给出的更复杂的例子。