Closed pardeep131085 closed 2 years ago
Hi,
I have look at the example here https://github.com/srikanth-lingala/zip4j#adding-entries-with-zipoutputstream Where we are zipping file using stream, but it was doing password protected each file instead of the zip file itself?
Here is the sample code
ainfo has filename and byte []
final ZipParameters zipParameters = createZipParameters(); final ByteArrayOutputStream bos = new ByteArrayOutputStream(); final ZipOutputStream zos = new ZipOutputStream(bos, password.toCharArray()); for (AttachmentInfo ainfo : attachments) { zipParameters.setFileNameInZip(ainfo.getName()); zos.putNextEntry(zipParameters); zos.write(ainfo.getAttachment()); zos.closeEntry(); } zos.close(); bos.close(); return bos.toByteArray();
How I can just put password on zip file not on each file?
Zip encryption does not encrypt the complete zip file. It encrypts each entry that is being added to the zip file and writes to the zip. This is an expected behaviour according to the zip specification.
Hi,
I have look at the example here https://github.com/srikanth-lingala/zip4j#adding-entries-with-zipoutputstream Where we are zipping file using stream, but it was doing password protected each file instead of the zip file itself?
Here is the sample code
ainfo has filename and byte []
How I can just put password on zip file not on each file?