Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Password Protected Zip files and Archive::ZIP

by b10m (Vicar)
on Dec 17, 2003 at 19:12 UTC ( [id://315349]=note: print w/replies, xml ) Need Help??


in reply to Password Protected Zip files and Archive::ZIP

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
  • Comment on Re: Password Protected Zip files and Archive::ZIP

Replies are listed 'Best First'.
Re: Re: Password Protected Zip files and Archive::ZIP
by eclark (Scribe) on Dec 17, 2003 at 23:45 UTC

    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"; }
Re: Re: Password Protected Zip files and Archive::ZIP
by nimdokk (Vicar) on Dec 17, 2003 at 19:29 UTC
    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
        My general thought would be since I know if the file is encrypted, to simply pass that in as a parameter and make a system call to an unzip program (PKZIP in our case). Otherwise, simply make use of the Archive::ZIP module routines. Put it together into a small subroutine, pass it the zip file name as a required parameter and the password as an optional parameter. I might post some pseudo-code when I have something put together.


        "Ex libris un peut de tout"

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (9)
As of 2024-04-16 08:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found