Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

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

 
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 ]
 
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....
 
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...


 
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.
 
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
 
Ranch Hand
Posts: 227
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
Boost this thread!