Compress and then encrypt, or vice-versa?
Problem
I am writing a VPN system which encrypts (AES256) its traffic across the net (Why write my own when there are 1,000,001 others already out there? Well, mine is a special one for a specific task that none of the others fit). Basically I want to run my thinking past you to make sure I'm doing this in the right order. At the moment packets are just encrypted before being sent out, but I want to add some level of compression to them to optimize the tranfer of data a little. Not heavy compression - I don't want to max out the CPU all the time, but I want to make sure the compression is going to be as efficient as possible. So, my thinking is, I should compress the packets before encrypting as an unencrypted packet will compress better than an encrypted one? Or the other way around? I will probably be using zlib for the compression. Read more on the Super User blog.
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Fix for: Compress and then encrypt, or vice-versa?
If the encryption is done properly then the result is basically random data. Most compression schemes work by finding patterns in your data that can be in some way factored out, and thanks to the encryption now there are none; the data is completely incompressible. Compress before you encrypt.
Awaiting Verification
Be the first to verify this fix
Sign in to verify this fix