문제

I have a requirement stating that data compression and encryption should be performed.

However, I have doubts relating to which step should be performed first in order to optimize compression rate and execution time. How can I choose which step to perform first and the compression and encryption approach to use?

도움이 되었습니까?

해결책

I would strongly expect an "encrypt then compress" approach to give you almost no compression. Encrypted data shouldn't have any discernable patterns in it, which is basically what compression relies on.

Compress then encrypt.

As for which kind of encryption and compression to use - that entirely depends on your context, which you haven't given any information about. Heck, you may find that your data isn't compressible in the first place.

다른 팁

I think the usual order of doing things is first compress, then encrypt. Good encryption algorithms are rather CPU expensive, so it's better to reduce the size of data first before encrypting.

First you would be performing compression. You can use 7zip libraries for doing that. It does the encryption too, I think AES encryption.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top