Compression and Encryption… Which to apply first?

时光怂恿深爱的人放手 提交于 2019-12-13 01:41:48

问题


I am working on a remote backup project in C... I want to send data and compress as well as encrypt the data.

However I am confused whether to compress first or encrypt first!

What will be better?:

  1. Compress the data and then encrypt it
  2. Encrypt the data and then compress it

Also I am going to use zlib for compression. And I am wondering which encryption lib to use... Some people say libgcrypt is good. Suggestion for good encryption libraries(very easy to use) will be appreciated... :)

or is there anything that does both of the jobs?

Thanks!


回答1:


You should compress before encrypting.

Any good encryption algorithm will produce random-like data that will not compress well.




回答2:


My favorite easy to write, understand and use algorithm is blowfish. There are a few implementations at that link in a few liens of code.

It's roughly the same level of security as something like AES/DES, ie pretty much unbreakable. As with all crypto the real vulnerability is going to be you and your users!



来源:https://stackoverflow.com/questions/13181309/compression-and-encryption-which-to-apply-first

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!