0

While the compression of plain text the size was reduced approx. 2 times but after encryption of the same text and compression the sizes where almost equal. Why the size of encrypted does not differ from origin text file?

ie2020
  • 25
  • 7
  • Data compression is done with the intension of decreasing the size of data, while encryption is done to keep the data secret from third parties – Mohit Sharma Feb 21 '16 at 17:48
  • 1
    _Compress before encrypt._ Compression uses repetitions and patterns in the data to shrink the input but encryption is designed to remove all recognizable patterns that may help analysis so compressing pre-encrypted data won't help much. – Joachim Isaksson Feb 21 '16 at 17:54
  • 2
    possible duplicate [When compressing and encrypting, should I compress first, or encrypt first?](http://stackoverflow.com/questions/4676095/when-compressing-and-encrypting-should-i-compress-first-or-encrypt-first) – Artjom B. Feb 21 '16 at 17:57

1 Answers1

3

Encryption is designed to make the encrypted data appear as a random stream of bytes. Random streams do not compress because they do not have any internal patterns for the compression algorithm to work on.

If you want both compression and encryption then always compress the plain data and then encrypt the compressed data.

rossum
  • 15,344
  • 1
  • 24
  • 38