Open pheely opened 2 years ago
Please you may try:
public void encrypt(String plaintextFilePath, String encryptedFilePath,
String sender, String recipient)
throws PGPException, IOException, SignatureException, NoSuchAlgorithmException, NoSuchProviderException {
try (
InputStream input = Files.newInputStream(Path.of(plaintextFilePath));
OutputStream output = BouncyGPG.encryptToStream()
.withConfig(keyringConfig)
.withStrongAlgorithms()
.toRecipient(recipient)
.andSignWith(sender)
.binaryOutput()
.andWriteTo(new BufferedOutputStream(Files.newOutputStream(Path.of(encryptedFilePath)), BUFFER_SIZE));){
Streams.pipeAll(input, output);
//output.flush();
//output.close();
}
}
Describe the bug A file is encrypted in the same fashion as in EncryptMain. When trying to decrypt it using
gpg --decrypt
command, got the following message:To Reproduce Steps to reproduce the behavior (code sample)
Expected behavior
File should be decrypted as expected.
System (please complete the following information):
For encryption
For decryption:
Additional context Add any other context about the problem here.