srikanth-lingala / zip4j

A Java library for zip files and streams
Apache License 2.0
2.09k stars 313 forks source link

Provided EncryptionMethod.ZIP_STANDARD_VARIANT_STRONG is not supported #237

Closed SorinBela closed 4 years ago

SorinBela commented 4 years ago

Trying to create a ZipFile with _EncryptionMethod.ZIP_STANDARD_VARIANTSTRONG yields an ZipException: "Invalid encryption method".

This is because ZipOutputStream::CipherOutputStream does not accept _EncryptionMethod.ZIP_STANDARD_VARIANTSTRONG

StackTrace:

 net.lingala.zip4j.exception.ZipException: Invalid encryption method

    at net.lingala.zip4j.io.outputstream.ZipOutputStream.initializeCipherOutputStream(ZipOutputStream.java:193)
    at net.lingala.zip4j.io.outputstream.ZipOutputStream.initializeCompressedOutputStream(ZipOutputStream.java:174)
    at net.lingala.zip4j.io.outputstream.ZipOutputStream.putNextEntry(ZipOutputStream.java:74)
    at net.lingala.zip4j.tasks.AbstractAddFileToZipTask.addFileToZip(AbstractAddFileToZipTask.java:108)
    at net.lingala.zip4j.tasks.AbstractAddFileToZipTask.addFilesToZip(AbstractAddFileToZipTask.java:84)
    at net.lingala.zip4j.tasks.AddFilesToZipTask.executeTask(AddFilesToZipTask.java:26)
    at net.lingala.zip4j.tasks.AddFilesToZipTask.executeTask(AddFilesToZipTask.java:15)
    at net.lingala.zip4j.tasks.AsyncZipTask.performTaskWithErrorHandling(AsyncZipTask.java:46)
    at net.lingala.zip4j.tasks.AsyncZipTask.execute(AsyncZipTask.java:40)
    at net.lingala.zip4j.ZipFile.addFiles(ZipFile.java:292)
    at net.lingala.zip4j.ZipFile.addFile(ZipFile.java:245)
srikanth-lingala commented 4 years ago

ZIP_STANDARD_VARIANT_STRONG is not supported by zip4j because this encryption method is patent protected by PKWare and implementing this encryption method requires a license from PKWare. The reason it exists as an enum in zip4j is because clients can at least know the encryption method if an entry in zip is encrypted with this method.