Component for using Java to make a winzip AES compatible function is rare. I only find winzipaes from. The example code is minimal.
We experience a situation recently that we need to implement Winzip AES functionality in an rather old project, which is using JDK1.3.
Key points
Code Snippet
Encryption
String source =args[1];
String zipfile =args[2];
String password =args[3];
AesZipFileEncrypter enc = new AesZipFileEncrypter(zipfile);
enc.zipAndEncrypt(new File(source),password);
Decryption
String zipfile = args[1];
String dest = args[2];
String password= args[3];
AesZipFileDecrypter dec= new AesZipFileDecrypter(new File(zipfile));
dec.extractEntries(new File(dest), password);
Logic in a nutshell
First it uses simple zip algorithm to compress the file(s) or directory, then it add encryption on top of zip file. The file size is the same before and after encryption.
Download codes
winzip AES 256 bits java code demonstration
http://www.iedmund.com/dbwizard/zipaes_jdk13.zip
Reference
http://www.winzip.com/aes_info.htm
We experience a situation recently that we need to implement Winzip AES functionality in an rather old project, which is using JDK1.3.
Key points
- We use winzipaes from http://code.google.com/p/winzipaes/
- Because we will use it in a rather old project, we changed the source code of winzipaes to make it support jdk1.3. Officially they do not have such version
- We change the source code of its dependent third party component bouncycastle bcprov-jdk13-144.jar http://www.bouncycastle.org/ Basically we just add zipaes to precede all of its original packages so that it does not collide with the earlier bouncycastle package we are using in the main projects.
- We add a class to support normal zip operation in the prototype
version 0.9 Usage 1): zipaes encrypt source zipfile password 2): zipaes decrypt zipfile dest password 3): zipaes zip source zipfile 4): zipaes unzip zipfile dest Note source can be a file or directory(both should be in full path) dest should include full path example: java -jar zipaes.jar encrypt c:/decafe/ c:/temp/decafe.zip 123456 java -jar zipaes.jar decrypt c:/temp/decafe.zip c:/temp/ 123456 java -jar zipaes.jar unzip c:/temp/tt.zip c:/t1/ java -jar zipaes.jar zip c:/temp/temp2 c:/t1/tt.zip java -jar zipaes.jar encstr secretstr java -jar zipaes.jar decstr |
Code Snippet
Encryption
String source =args[1];
String zipfile =args[2];
String password =args[3];
AesZipFileEncrypter enc = new AesZipFileEncrypter(zipfile);
enc.zipAndEncrypt(new File(source),password);
Decryption
String zipfile = args[1];
String dest = args[2];
String password= args[3];
AesZipFileDecrypter dec= new AesZipFileDecrypter(new File(zipfile));
dec.extractEntries(new File(dest), password);
Logic in a nutshell
First it uses simple zip algorithm to compress the file(s) or directory, then it add encryption on top of zip file. The file size is the same before and after encryption.
Download codes
winzip AES 256 bits java code demonstration
http://www.iedmund.com/dbwizard/zipaes_jdk13.zip
Reference
http://www.winzip.com/aes_info.htm
留言
張貼留言