Set password in zip files

Discuss about plugins that don't have a dedicated forum
Post Reply
User avatar
Juan Carlos
Posts: 920
Joined: Mon Sep 06, 2010 1:02 pm

Set password in zip files

Post 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.
User avatar
airsoftsoftwair
Posts: 5626
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Set password in zip files

Post 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})
User avatar
Juan Carlos
Posts: 920
Joined: Mon Sep 06, 2010 1:02 pm

Re: Set password in zip files

Post 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.
User avatar
airsoftsoftwair
Posts: 5626
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Set password in zip files

Post 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})
User avatar
Juan Carlos
Posts: 920
Joined: Mon Sep 06, 2010 1:02 pm

Re: Set password in zip files

Post by Juan Carlos »

Thank you, Andreas, now it works.
User avatar
Juan Carlos
Posts: 920
Joined: Mon Sep 06, 2010 1:02 pm

Re: Set password in zip files

Post by Juan Carlos »

Hi, Andreas, how is going the Zip plugin update? Soon, Will be possible open files from one Zip file with password?
User avatar
airsoftsoftwair
Posts: 5626
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Set password in zip files

Post by airsoftsoftwair »

When it's done :)
User avatar
Juan Carlos
Posts: 920
Joined: Mon Sep 06, 2010 1:02 pm

Re: Set password in zip files

Post 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.
User avatar
airsoftsoftwair
Posts: 5626
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Set password in zip files

Post by airsoftsoftwair »

Do zip.SetDefaultPassword() or passing a password to zip.ExtractFile() not work for you?
Post Reply