Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nén trước rồi mã hóa hay mã hóa trước rồi nén? #240

Open
xluffy opened this issue Mar 29, 2024 · 1 comment
Open

Nén trước rồi mã hóa hay mã hóa trước rồi nén? #240

xluffy opened this issue Mar 29, 2024 · 1 comment

Comments

@xluffy
Copy link
Owner

xluffy commented Mar 29, 2024

Neither:

  • Encrypting first and then compressing does not work.
  • Compressing first can leak information about plaintext content through the ciphertext length, as poncho mentioned in comments to another answer.

Specifically, compression allows an attacker who can control parts of the message that is encrypted to reveal things about the other, secret parts, like cookies in the case of web traffic. It is most dangerous in a live protocol like TLS. Some forms of compression (e.g. truly constant bitrate lossy video/audio compression) may be immune to such attacks (but even then there might be side channel attacks due to the compression).

In most cases you should just encrypt the uncompressed data and be done with it.

Data storage and transmission is usually cheap enough. If you cannot live without compression, you must do it first, but then you have to really know what you are doing and likely accept at least some loss of security.

@tinnguyenwork
Copy link

What if you want to encrypt a folder? Zip without compression and then encrypt the archive https://superuser.com/questions/411394/zip-files-without-compression

More TIL: https://www.passwordstore.org/ is a password manager using gpg under the hood

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants