import de.idyl.winzipaes.AesZipFileEncrypter;
import de.idyl.winzipaes.impl.AESEncrypterBC;
File aNewZipFile = new File("/tmp/foo.zip");
File existingUnzippedFile = new File("/tmp/src.txt");
// We use the bouncy castle encrypter, as opposed to the JCA encrypter
AESEncrypterBC encrypter = new AESEncrypterBC();
encrypter.init("my-password", 0); // The 0 is keySize, it is ignored for AESEncrypterBC
AesZipFileEncrypter zipEncrypter = new AesZipFileEncrypter(aNewZipFile, encrypter);
zipEncrypter.add(existingUnzippedFile, "src.txt", "my-password");
// remember to close the zipEncrypter
zipEncrypter.close();
您可以使用 Winzip (v9 +)或7za (即7zip)在 Mac 上解压缩“/tmp/foo.zip”,使用密码“ my-password”。