Closed hakwolf closed 8 months ago
Hi!
To change the encryption method to be used with the Zip format, you can use the setFormatProperty
and pass to it the native 7-zip format option em
as follows:
Bit7zLibrary lib{};
BitFileCompressor compressor( lib, BitFormat::Zip );
compressor.setFormatProperty( L"em", L"AES256" ); // ZipCrypto, AES128, AES192, AES256
compressor.setPassword( "password" );
compressor.compressFile( "path/to/file.txt", "path/to/archive.zip" );
No encryption is performed by default if you don't specify a password.
If you specify a password, the default encryption method ZipCrypto
is used unless you explicitly set a different method via setFormatProperty
.
Please note that the setFormatProperty
only accepts wide string literals (regardless of the CMake option BIT7Z_USE_NATIVE_STRING
).
i will both use 7z and zip format . if I use choose 7z format, use method is any diffrent then zip?
BitFileCompressor compressor{ lib, BitFormat::SevenZip };
compressor.setFormatProperty( L"em", L"AES256" ); // ZipCrypto, AES128, AES192, AES256
compressor.setPassword( "password" );
compressor.compressFile( "path/to/file.txt", "path/to/archive.zip" );
Unfortunately, the 7z format doesn't support any other encryption method than AES256.
As such, 7-zip doesn't accept the em
option when using the 7z format and returns an error during compression if such an option is used, causing bit7z to throw an exception to notify the user.
Feature description
how can I use this lib to set 7Z ,zip compress file as none, AES-128,AES-256 encrypted.
Additional context
No response
Code of Conduct