Odd situation, and I won't go into details about why our present circumstances require it. But, I'm looking for a way to force gpg to use compression. My testing is suggesting that the following command ignores the '-z' option:

gpg -z 6 -e test.zip

Note that the object to be encrypted is a zip archive. I'm using the bouncycastle java library to crack open output blob and it doesn't appear to be using pgp-compression.

My suspicion is that gpg detects that the file to be encrypted is already compressed and doesn't re-compress it. Unfortunately that's precisely what I need it to do.

Can anyone confirm this is the case (gpg doesn't re-compress)? And if so, is there a way to force it? Thanks.

  • Why would you want to compress an already compressed file. The results may result in a file significantly larger than the original! – mdpc Jul 17 '13 at 19:06
  • Agreed - it is a silly thing to need. But I need it :) – pedorro Jul 17 '13 at 19:15
  • 1
    Using -v with your command shows your suggest is right; neither the man page nor the esoteric options manual know anything about enforcing compression of compressed contents. Probably you're out of luck. – Jens Erat Jul 17 '13 at 19:23

If you look at the relevant source file (encode.c; search for is_file_compressed), GPG will still do the compression if MDC is disabled. So passing --disable-mdc should do the trick.

If you don't want to disable MDC, then you should probably compile your own copy of GPG with the compression check removed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.