I been trying to creat a password protected zip file i come acorss this lirbary net.lingala.zip4j it seems that it use to protect the zip file with password.
but now i have been trying all i can do is protect the files not the zip it self, the diference is the zip can be opened and files inside can be deleted from the zip
i will show my current code but i have tryed many codes but all see to need this imports import net.lingala.zip4j.util.Zip4jConstants; import net.lingala.zip4j.core.ZipFile;
And does seem to not exist anymore in updated vertion of zip4j
any knows a way around this so i can protect the zip file it self?
try (ZipFile zipFile = new ZipFile("settings.zip", (mysqllogFile[1]).toCharArray())) {
ZipParameters zipParameters = new ZipParameters();
zipParameters.setEncryptFiles(true);
zipParameters.setEncryptionMethod(EncryptionMethod.AES);
zipParameters.setAesKeyStrength(AesKeyStrength.KEY_STRENGTH_256);
zipFile.addFile("token", zipParameters);
zipFile.addFile("mysqllog", zipParameters);
// delete the original files
File tokenFile = new File("token");
tokenFile.delete();
File mysqlLogFile = new File("mysqllog");
mysqlLogFile.delete();
System.out.println("Files zipped successfully!");
} catch (ZipException e) {
e.printStackTrace();
}