Page 1 of 1

Set password in zip files

Posted: Tue Sep 10, 2019 6:31 pm
by Juan Carlos
I try to ziped a picture file with password and it or not works or I don't know how set it.

Code: Select all

@REQUIRE "zip", {InstallAdapter = True}

@DISPLAY {Title="Window", Width=640, Height=480}

zip.OpenArchive(1, "test.zip", #MODE_WRITE)

;zip.AddFile(1, "House.jpg") ;Here the code ziped the picture.

;Below the code where you choose the mode and password doesn't work.
zip.AddFile(1, "House.jpg", {#ZIP_EM_AES_256, #ZIP_CM_BZIP2})
zip.SetDefaultPassword(1, "Hello")

;This below line neither work.
;zip.SetFileEncryption(1, "House.jpg", {#ZIP_EM_AES_256, "Hola"})

zip.CloseArchive(1)

SystemRequest("Noticie", "File ziped", "Ok", #REQICON_INFORMATION)
End()

Where is the fault because there aren't examples to this and for make a little Hollyzip.

Re: Set password in zip files

Posted: Wed Sep 11, 2019 8:33 pm
by airsoftsoftwair
You obviously don't pass the table arguments to zip.AddFile() correctly. The line should be:

Code: Select all

zip.AddFile(1, "House.jpg", {Encryption = #ZIP_EM_AES_256, Compression = #ZIP_CM_BZIP2})

Re: Set password in zip files

Posted: Wed Sep 11, 2019 9:52 pm
by Juan Carlos
Sorry but only shows this message:
A zip error has occurred!
Even I added the field Password = "Hello" and also show the same message.
This is only to zip one file.

Re: Set password in zip files

Posted: Sun Sep 15, 2019 6:15 pm
by airsoftsoftwair
Juan Carlos wrote: Wed Sep 11, 2019 9:52 pm Sorry but only shows this message:
A zip error has occurred!
Even I added the field Password = "Hello" and also show the same message.
This is only to zip one file.
Ok, looks like the zip plugin currently doesn't support bzip2. So just do the following and you're all set:

Code: Select all

zip.AddFile(1, "House.jpg", {Encryption = #ZIP_EM_AES_256})

Re: Set password in zip files

Posted: Mon Sep 16, 2019 10:52 am
by Juan Carlos
Thank you, Andreas, now it works.

Re: Set password in zip files

Posted: Fri Jul 10, 2020 9:02 am
by Juan Carlos
Hi, Andreas, how is going the Zip plugin update? Soon, Will be possible open files from one Zip file with password?

Re: Set password in zip files

Posted: Sat Jul 11, 2020 3:00 pm
by airsoftsoftwair
When it's done :)

Re: Set password in zip files

Posted: Thu Nov 25, 2021 4:51 pm
by Juan Carlos
Hello, how do you go with the plugin update? I need for my last project game to use the zip file with password to proctect the game's files, and it is useful for other programmers, for example OpenBor has this option in its games.
Thank you.

Re: Set password in zip files

Posted: Fri Nov 26, 2021 9:31 pm
by airsoftsoftwair
Do zip.SetDefaultPassword() or passing a password to zip.ExtractFile() not work for you?