Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Password Protected Zip files and Archive::ZIP

by nimdokk (Vicar)
on Dec 17, 2003 at 18:58 UTC ( [id://315345]=perlquestion: print w/replies, xml ) Need Help??

nimdokk has asked for the wisdom of the Perl Monks concerning the following question:

I'm just playing around with the Archive::ZIP module to create and extract files that we receive. It works great for non-password protected zipfiles. However, we do get some files that have been password protected. I'm just curious to see if there might not be a way to work with password protected files using this module. I have not yet located anything in the documentation that would help with this. I'm still playing and may come up with an answer on my own as well. Thanks.


"Ex libris un peut de tout"
  • Comment on Password Protected Zip files and Archive::ZIP

Replies are listed 'Best First'.
Re: Password Protected Zip files and Archive::ZIP
by b10m (Vicar) on Dec 17, 2003 at 19:12 UTC

    Good call, unfortunately the docs provide you with:

    isEncrypted()

    Return true if this member is encrypted. The Archive::Zip module does not currently create or extract encrypted members.

    At least you can check wheter a file is protected, and give a decent error message :)

    Or you can first check wheter the file is encrypted and, if so, pass it on to some `unzip` system call. Not nice, but as I see it, it can't be done different (please prove that I'm wrong, anyone :)

    --
    b10m

      Because of this limitation, I am using Info-ZIP's unzip in a system call. It is not very elegant but it works.

      system("unzip -L -P $password -n $zipfile -d $outputdir"); my $retcode = ($? >> 8); if ($retcode) { ## abnormal failure die "unzip returned abnormal exit code $retcode"; }
      I found that out just a few minutes ago digging through more documentation on the module. I might see what I can come up with to account for the presence or absence of passwords on those files. Just have to keep playing with it. :-)


      "Ex libris un peut de tout"
        Please post here, if you come up with anything, I would be interested to hear your results, as I am currently planning a similar scheme.

        Regards,
        Gerard

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://315345]
Approved by davido
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (8)
As of 2024-04-18 14:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found