I am writing a Java application and part of it involves zipping/unzipping folders with a password encrypted. The code I use in Java to run terminal commands is:
p = Runtime.getRuntime().exec(command);
p.waitFor();
When I choose to zip a particular folder, the terminal call is:
command = zip -P password -r encrypted.zip folderIWantToZip
When I choose to unzip a particular folder, the terminal call is:
command = unzip -P password encrypted.zip
I detect when a user enters a wrong password (when trying to unzip) if the p.waitFor()
value is 1 and not 0.
I am testing my application on a Mac and it seems to be working fine. I am assuming that these terminal calls will work exactly the same on Linux machines as well and I should be getting the same result.
I was wondering what would be the equivalent terminal/command prompt commands on a Windows machine to zip and unzip folders with password encryption. I have heard that this is not possible on command prompt without downloading a third party software like 7zip. In this case, what would be the equivalent terminal commands using 7zip/some other equivalent third party software such that this application would work on Windows?