This project is read-only.

SFX Encrypted Archive

Aug 4, 2009 at 8:52 PM

Is it possible to create a self-extracting encrypted archive?  Would I have to create a custom sfx module?

I tried the following code, but I get a "7-Zip: Unsupported method" error after it asks me where to extract the file to.  If I manually use 7zip to extract the file it works fine.

Dim sfx As SevenZipSfx = New SevenZipSfx()
Dim tmp As SevenZipCompressor = New SevenZipCompressor()
Dim ms As MemoryStream = New MemoryStream()

tmp.CompressionLevel = CompressionLevel.High
tmp.ZipEncryptionMethod = ZipEncryptionMethod.Aes256
tmp.EncryptHeadersSevenZip = True

'Compress the file
tmp.CompressFilesEncrypted(ms, pass, filename)

'Make the compressed file self-extracting
sfx.MakeSfx(ms, filename & ".exe")

Thanks, Murray

Aug 4, 2009 at 9:37 PM

I was able to use the sfx module that comes with 7zip to successfully make an encrypted sfx archive.  Does anyone know whether there are any licensing restrictions on doing this?

Aug 6, 2009 at 6:35 AM

All 7zip sfx modules included in SevenZipSharp code (sfx directory), including sfx modules that come with 7z-zip, are covered by LGPL licence.

Aug 6, 2009 at 2:39 PM

Thanks.  And thanks for all the work.  It was pretty nice to be able to complete a project and add the code to encrypt and sfx in only 8 lines.  Great work!