Is there a way to encrypt/decrypt using Bouncy Castle without using compression

Tags: , , ,

I’m looking for a way to encrypt/decrypt files/byte arrays without calling compression of input. To be more precises don’t want to use something like

ByteArrayOutputStream bOut = new ByteArrayOutputStream();
PGPCompressedDataGenerator comData = new PGPCompressedDataGenerator(algorithm);
PGPUtil.writeFileToLiteralData(, PGPLiteralData.BINARY, new File(fileName));

Any reference, code sample is more than welecome, Thanks.


You avoid adding compression in PGP by simply not adding the code that does it. For your question to be sensible, I would expect you to post an example that has signing/encryption + compression, then we could suggest how to remove the compression bits.

Actually the simplest way for you might be to just set “uncompressed” like this:

new PGPCompressedDataGenerator(algorithm, CompressionAlgorithmTags.UNCOMPRESSED)

Source: stackoverflow