I have this program which encrypts multiple files using AES then compress it using LZO into one single file. The problem is that the final file is almost equal in size than all the files which means LZO is not doing his job properly. Also, if I only encrypt files, the size is almost the same.
I've also tried to compress data and then encrypt it, but the result is the same.
AES can't be compressed at all or it can't be compressed by LZO?
What do you recommend to use in compression for maximum compatibility with AES? I want both speed and good compressio ratio. Like, over 100mb/s speed and ~2.0 compression ratio. Thanks.

  • 3
    $\begingroup$ Compress before encrypting, not after. The only way to encrypt a ciphertext at all is by breaking the encryption. (But that might cause some security issues, the CRIME attack against TLS was due to compression. $\endgroup$ Jan 28, 2016 at 10:28
  • $\begingroup$ @CodesInChaos I've tried that already, and the result is the same. I edited the question. Sorry for the lack of informations. $\endgroup$
    – Shockwave
    Jan 28, 2016 at 10:57
  • 2
    $\begingroup$ @Shockwave: if your "I've tried that already" refers to "Compress before encrypting, not after", then you need to better understand the nature of the content of your "multiple files" and find or devise a compression algorithm suitable for that. If your "multiple files" are already compressed (including many common sound, image, video formats), that will be very hard. $\endgroup$
    – fgrieu
    Jan 28, 2016 at 11:17
  • $\begingroup$ @fgrieu 99% of the files are text files, 1% are TGA images. They are not encrypted before by me. They are as they were made by the graphic editor. Sure, I would like to compress also a lot of TGA files, but for now that's what I've tested on... $\endgroup$
    – Shockwave
    Jan 28, 2016 at 11:23
  • 2
    $\begingroup$ @Shockwave: you wrote " I've tried that already, and the result is the same". I find it unlikely that lzo (with default parameters) fails to compress text files, even more the concatenation of text files. I guess that you did not correctly "Compress before encrypting, not after". $\endgroup$
    – fgrieu
    Jan 28, 2016 at 11:41


Browse other questions tagged or ask your own question.