Is it better to encrypt a message and then compres

2019-01-17 15:46发布

I have the assumption there is no added protection at all.

8条回答
成全新的幸福
2楼-- · 2019-01-17 15:55

There is no difference in security provided.

查看更多
贪生不怕死
3楼-- · 2019-01-17 15:57

You should compress before encrypting.

Encryption turns your data into high-entropy data, usually indistinguishable from a random stream. Compression relies on patterns in order to gain any size reduction. Since encryption destroys such patterns, the compression algorithm would be unable to give you much (if any) reduction in size if you apply it to encrypted data. 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.

Compression before encryption also slightly increases your practical resistance against differential cryptanalysis (and certain other attacks) if the attacker can only control the uncompressed plaintext, since the resulting output may be difficult to deduce.

查看更多
ら.Afraid
4楼-- · 2019-01-17 15:58

There is no difference in the security provided, but because of the way compression algorithms work, you are probably going to get better compression if you compress first then encrypt.

Compression algorithms exploit statistical redundancies (such as those that exist in natural language or in many file formats) in the data which should be eliminated when you encrypt it, therefore an encrypted message shouldn't be able to be compressed all that well.

From the wikipedia article:

However, lossless data compression algorithms will always fail to compress some files; indeed, any compression algorithm will necessarily fail to compress any data containing no discernible patterns. Attempts to compress data that has been compressed already will therefore usually result in an expansion, as will attempts to compress all but the most trivially encrypted data.

查看更多
萌系小妹纸
5楼-- · 2019-01-17 16:06

There is no added security (as compression is not a security mechanism), but a properly encrypted message shouldn't be easily compressible (i.e. rule of thumb: if you can significantly compress an encrypted message, something is wrong).

Therefore, compress then encrypt.

查看更多
Summer. ? 凉城
6楼-- · 2019-01-17 16:06

Look here: Super User thread about compression && encryption or the other way around

They have a complete and detailed answer to your question (witch is compress then encrypt, by the way).

查看更多
SAY GOODBYE
7楼-- · 2019-01-17 16:10

Yep, there should be no difference in the security provided.

查看更多
登录 后发表回答