getnamo / 7zip-cpp

Fork of SevenZip++ for modern builds.
Other
221 stars 93 forks source link

Encrypt filenames #48

Open yoyixms opened 3 years ago

yoyixms commented 3 years ago

Hi, I was able to set a password using the compressor. but it seems it does not encrypt the file names. is this possible?

Thanks!

getnamo commented 3 years ago

At a glance, looks like 7zip com API needs -mhe option passed to encrypt archive header (ref https://www.cnx-software.com/2011/02/22/aes-256-encryption-and-file-names-encryption-with-7-zip-7z/), likely somewhere around https://github.com/getnamo/7zip-cpp/blob/0cbebfbef54731db9df49baaa8adde38936eeed3/7zpp/SevenZipCompressor.cpp#L157 or https://github.com/getnamo/7zip-cpp/blob/0cbebfbef54731db9df49baaa8adde38936eeed3/7zpp/ArchiveUpdateCallback.cpp needs to be modified to update archive with desired settings, I'm not 100% sure since it's been a while since I've looked at this.

That should hopefully get you started on how to modify source to add the feature.

NB: These were the changes done by https://github.com/KocourKuba to add encryption support (https://github.com/getnamo/7zip-cpp/commit/661c0f27cbbdf3ca4560ec9e3f399d8d3169c42d#diff-3087414f04c94500ca05e45e07d945c3a9df425ebd2f77de5e34e38ea4df95f5)