跳到主要內容

Winzip AES with Java

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
  • 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
Usage
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

留言

這個網誌中的熱門文章

Setup Tomcat HTTPS (with JDK 8 to Java 15) in 2 mins

  Setup Tomcat 9 HTTPS/SSL To have a quick view, you may see the video(s): https://www.youtube.com/watch?v=WDGoF13vhZU 1. Generate Keystore I am using JDK 15 to generate the keystore. But the steps are similar with Tomcat 6 + openjdk 8(as I have tried it before writing this doc) Use “keytool” command to create a self-signed certificate. During the keystore creation process, you need to assign a password and fill in the certificate’s details. D:\apache-tomcat-9.0.38\conf>keytool -genkey -alias tomcatks -keyalg RSA -keystore D:\apache-tomcat-9.0.38\conf\tomcatks When enter the passwords during generation, please make sure the two passwords you entered are the SAME. This is the requirement of Tomcat. Here is the abstract from Tomcat installation  Finally, you will be prompted for the key password , which is the password specifically for this Certificate (as opposed to any other Certificates stored in the same keystore file). You MUST use the same password here as was used f...

全港乒乓球錦標賽 09 甲組賽事

今天換個輕鬆一點的題目,看看精彩的乒乓球 我在這裏介紹有個Channel有很清晰的乒乓球比賽片段,是全港乒乓球錦標賽甲組的賽事,其中有高澤禮在香港比賽的最新的片段 ,我相信這種場面很少有機會見到,因為,第一是業餘對專業,我在電視中都未看過,是認真比賽的那一種,不是國家隊奧運完結之後派冠軍來的表演賽,大家放軟手腳逗下逗下的那一種,可觀性高很多,第二,拍攝很有現場感,就算電視台都很少見到這樣的角度,就像親臨現場一樣。 雖然高禮澤貴為國際頂級球員,但落到這場地區賽事的時候都非常認真;雖然他技術高幾班,但認真程度從有球滴死對手時,球証看不清楚,而他正領先下,他都幫忙指証便可看出。 他是港隊中又有善又認真的專業球員,希望給年輕球員有認真對陣高水準球員的機會。 http://www.youtube.com/watch?v=nSo6Kg0vEus (這幾局可能是平均分數最接近的比賽) http://www.youtube.com/watch?v=LTJuYI906AI 還有很多其他攝錄質素很高的片段 謝嘉俊(港隊代表) vs 趙頌熙(港隊少年代表,在港有乒乓神童之稱,曾在11歲時贏得中國全國兒童賽冠軍) http://www.youtube.com/watch?v=zNEG2CzrDMI 謝嘉俊(港隊代表) vs 王德龍 09全港公開乒乓球單項錦標賽 Part 1 http://www.youtube.com/watch?v=OIeSo9V5V-0 趙頌熙(青少年港隊代表) 對 陳嘉耀 09全港公開乒乓球單項錦標賽 決勝局 Part 1 http://www.youtube.com/watch?v=jpaXjLL1bT4 陳文鋒 對 蔡鎮滔 2009全港公開乒乓球單項錦標賽 Part 2 http://www.youtube.com/watch?v=ZdcG8-I0buw&feature=channel_page 或者可以直接溜灠這個channel頻道 http://www.youtube.com/ppball

IIS connects to Tomcat. Bug in IIS URL redirect, http2

IIS connects to Web/Application Server Tomcat 9 IIS (Internet Information Server 10) on Windows 2016 server Plesk dropped support for connecting Tomcat from IIS. It is disgraceful. I was so disappointed to learn that. However, another exciting opportunity opened up as I learnt URL rewrite is powerful enough to take over the job and even with more elegant simplicity. So I gave it a try. Even without knowing many of its features, I was able to set it up that one of the sites mysub.yourdomain.com (not real domain, just as an example and I tried a few sites in my server) is pointing to a tomcat localhost at 8080. It sounds good enough. Right?   However, after setting the original site mysub.yourdomain.com for using https. All browsers in desktop platform and Android platform seemed to work. But browser in iOS version failed to open the https. After a few digging, some said in forum that it was a known bug https://stackoverflow.com/questions/49141004/ios-10-3-3-not-working-w...