This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
I am using java.util.zip.* pacake in order to zip some files. My question is: Is it possible to password protect this zip using Java API? If yes, a code example will be helpful. Thanks!
What about Password-Based Encoding with JCE from the java security package? Can't that API be applied on the zip file? [ October 31, 2007: Message edited by: Roy Cohen ]
You can certainly use JCE to encrypt a ZIP file, but that will not result in a file WinZip can open. The java.util.zip package simply doesn't support passwords.
"Password-protected" only means something for a file format if that file format provides a way to provide a password and prompt for it. So general questions like that are useless.
It's possible, for example, that iText provides a way to password-protect a PDF file. (If PDF even supports such a thing, which I don't know.) But you'd have to look in the iText documentation for that. And of course iText wouldn't be able to password-protect a MS Word file (again, if such a thing is even possible). [ October 31, 2007: Message edited by: Paul Clapham ]
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35443
9
posted
0
Paul is good at guessing
PDF, DOC and XLS all support password-protection, but like he said, that's something inherent in the format, not something that can be added via a Java API.
While it's possible to write a Java ZIP package that supports passwords like the ones WinZip/PKZIP use, I'm not aware that any of the existing ones do.
(Just for completeness sake - yes, iText can handle PDF passwords).
Andrew Carney
Ranch Hand
Joined: Oct 17, 2006
Posts: 96
posted
0
Ok so I'll just have java run WinZip from command line to create a zip with password...