logoalt Hacker News

sreantoday at 3:49 PM1 replyview on HN

Then there is this eternal conversation about whether on should encrypt and then compress or compress and then encrypt.

Encrypted data will not compress well because encryption needs to remove patterns and patterns are what one exploits for compression.

If you compress and then encrypt, yes you can leak information through the file sizes, but there isn't really a way out of this. Encryption and compression are fundamentally at odds with each other.


Replies

smillikentoday at 4:09 PM

Compress then encrypt is not an option because your encryption is broken if it can be compressed at all. Mathematically it's a near certainty that the compression would increase the file size when given an encrypted input.

show 1 reply