mw99 / DataCompression

Swift libcompression wrapper as an extension for the Data type (GZIP, ZLIB, LZFSE, LZMA, LZ4, deflate, RFC-1950, RFC-1951, RFC-1952)
Apache License 2.0
286 stars 57 forks source link

Is it possible to do gzip() a file with a password? If so, how please? #34

Closed waelsaad closed 8 months ago

waelsaad commented 8 months ago

I would like to zip and unzip my files with a password if possible, I am not sure ! Thanks.

                if let compressedData = html.data.gzip() {
                    try compressedData.write(to: filePath)
                }
mw99 commented 8 months ago

Encryption is not supported by this library. But it is of course possible to add encryption after compression. Maybe you can find what you need here: https://developer.apple.com/documentation/cryptokit/performing_common_cryptographic_operations

Just for info, compression should be performed before encryption. If not, the high entropy of encrypted data streams will cause a very poor compression rate, regardless of which compression algorithm you use.