Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a definitive order to perform data compression and encryption

I have a requirement stating that data compression and encryption should be performed.

However, I have doubts relating to which step should be performed first in order to optimize compression rate and execution time. How can I choose which step to perform first and the compression and encryption approach to use?

like image 962
venkat Avatar asked Dec 19 '25 17:12

venkat


1 Answers

I would strongly expect an "encrypt then compress" approach to give you almost no compression. Encrypted data shouldn't have any discernable patterns in it, which is basically what compression relies on.

Compress then encrypt.

As for which kind of encryption and compression to use - that entirely depends on your context, which you haven't given any information about. Heck, you may find that your data isn't compressible in the first place.

like image 97
Jon Skeet Avatar answered Dec 21 '25 06:12

Jon Skeet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!