From: Jochen H. <Hoe...@In...> - 2003-08-20 09:30:03
|
On Tuesday 19 August 2003 17:47, Benveniste, Joel wrote: > Hi, > Does anyone know how we can add the password protection function to this package?? > I know that java.util.zip does not handle this function and have read that the spec is found > in pkzip's APPNOTE.TXT but I am not yet sure how to implement this functionality.. You may want to change both ZipFile and ZipInputStream to support decryption, or ZipOutputStream to support encryption. You need to check if bit 0 of the general purpose flags in the local header is set. In ZipInputStream the general purpose flags are already read to "flags" in getNextEntry(). So just check for "flags & 1". In ZipFile, you need to modify getInputStream() to read in this flag. The decryption can be done by a FilterInputStream that you need to write. Then give this FilterInputStream to InflaterInputStream and it should work. Note that the encryption is very weak: ftp://utopia.hacktic.nl/pub/crypto/cracking/pkzip.ps.gz Jochen -- Jochen Hoenicke, University of Oldenburg, 26111 Oldenburg, Germany Email: hoe...@in... Tel: +49 441 798 3124 |