Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.util.zip and a password-protected zip file

 
Stephen Huey
Ranch Hand
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to unzip files from within my Java program. Before I would try to just exec a process that would run pkunzip on my files, but I've been trying that on a Win2003 machine and would always get a strange error from Windows saying something about the environment not being set up (and yes, I was hardcoding the path to pkunzip). Anyway, for some strange reason I don't get that error anymore (and I didn't change anything on the server myself), but I had already started working on trying to use the java.util.zip package's classes to do this from pure Java code, so I'm now wondering if there's any way from within this Java package to unzip an encrypted (password-protected) zip file. Here's what I have so far:



[ August 24, 2004: Message edited by: Stephen Huey ]
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reference Website
How do I unzip a file that is password-protected?

This will hekp you....
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the article provided by somkiat, it said that "The Java classes that read Zip files, e.g. ZipInputStream, do not support decrypting password-protected Zip files."

Your application must find a way to let the user specify the password to decrypt the zip file... You might need to find the documents or manuals that explain how to deal with encryption and decryption with a certain zip file...

Just my 2 cents..
 
Stephen Huey
Ranch Hand
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would be easy to obtain a password from the user, but in looking at the API, I'm not really sure how to use the password obtained. However, I'm guessing this means that all the bytes of the file need to be decrypted using that password string...


 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to I/O and Streams since Zip operations are Input/Output and Stream operations.
 
Martin Matula
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote a simple class that can deal with a certain type of password-protected ZIPs in Java - here is more info: http://blog.alutam.com/2009/10/31/reading-password-protected-zip-files-in-java/
Martin
 
Santosh Kumar Nayak
Ranch Hand
Posts: 147
Eclipse IDE IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Team,

I have a zipped file and I want to add a password to the zipped file . Such that while unzipping the contents of the file it should ask for the password.

It is possible via Java API ?

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic