You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello Srikanth,
Hopefully all is well with you. Thanks your wonderful library.
We are using zip4j-1.3.2 library to create password encrypted zip file.
And then, when we try to unzip the file with the tool 7-zip, we are getting the following error and the issue is intermittent, ERROR: CRC Failed in encrypted file. Wrong password
As follows the code util to create the zip file,
import java.io.File;
import net.lingala.zip4j.core.ZipFile;
import net.lingala.zip4j.exception.ZipException;
import net.lingala.zip4j.model.ZipParameters;
import net.lingala.zip4j.util.Zip4jConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ZipFileUtil {
private static final Logger logger = LoggerFactory.getLogger(ZipFileUtil.class);
public static final String ZIP_WITH_DOT = ".zip";
public static final String DOT = ".";
/**
* Method for creating password protected zip file
*
* @param sourcePath
* @throws ZipException
*/
public String compressWithPassword(String sourcePath, String zipFilePassword) throws ZipException {
try {
//String destPath = sourcePath + ".zip";
String zipFileName=sourcePath.substring(0,sourcePath.lastIndexOf(DOT))+ ZIP_WITH_DOT;
logger.info("ZIP File Name " + zipFileName);
ZipFile zipFile = new ZipFile(zipFileName);
// Setting parameters
ZipParameters zipParameters = new ZipParameters();
zipParameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
zipParameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_ULTRA);
zipParameters.setEncryptFiles(true);
zipParameters.setEncryptionMethod(Zip4jConstants.ENC_METHOD_AES);
zipParameters.setAesKeyStrength(Zip4jConstants.AES_STRENGTH_256);
// Setting password
zipParameters.setPassword(zipFilePassword);
zipFile.addFile(new File(sourcePath), zipParameters);
return zipFileName;
} catch (ZipException e) {
logger.error("exception while zip for file:" + sourcePath + " error:" + e.getMessage());
throw new ZipException(e);
}
}
}
Please advice the best solution for this issue. . In order to fix it, we suggested to upgrade to the version2.11.5 to my boss but he is asking the root cause. My boss is telling that we cannot just upgrade the library in production without proper root cause to explain to management.
Thank you,
Sreenivasulu N
The text was updated successfully, but these errors were encountered:
sreenivasulun2007
changed the title
ERROR: CRC Failed in encrypted file. Wrong password - while unzip using WinRAR 6.24
ERROR: CRC Failed in encrypted file. Wrong password - while unzip using 7-zip
Jan 22, 2024
Hello Srikanth,
Hopefully all is well with you. Thanks your wonderful library.
We are using zip4j-1.3.2 library to create password encrypted zip file.
And then, when we try to unzip the file with the tool 7-zip, we are getting the following error and the issue is intermittent,
ERROR: CRC Failed in encrypted file. Wrong password
As follows the code util to create the zip file,
Please advice the best solution for this issue. . In order to fix it, we suggested to upgrade to the version2.11.5 to my boss but he is asking the root cause. My boss is telling that we cannot just upgrade the library in production without proper root cause to explain to management.
Thank you,
Sreenivasulu N
The text was updated successfully, but these errors were encountered: