How to Decrypt an DES encrypted Zip file
843811Nov 19 2007 — edited Nov 19 2007Hello
I have an Encrypted Zip File. It is Encrypted Using RSA and DES
I have tool for decrypting the RSA encrypted Zip file using Public Key and Private Key. The problem is after Decrypting the RSA encrypted zip files there are other zip files which are encrypted using DES encryption.And a password is necessary for that. How Can i find that password. The necessary code for that DES Decryption in the tool i have is as follows
if(!s.equals(""))
{
progressLabel.setText("Decrypting with day Password...");
progressBar.setVisible(true);
String s6 = (new File(sPath)).getName().substring(0, (new File(sPath)).getName().lastIndexOf("."));
File file1 = new File((new StringBuilder()).append(s5).append(ZipUtils.fileSep).append(s6).toString());
file1.mkdirs();
File file3 = new File((new StringBuilder()).append(s4).append(ZipUtils.fileSep).append(s6).toString());
file3.mkdirs();
String as[] = (new File((new StringBuilder()).append(s3).append(ZipUtils.fileSep).append(s6).toString())).list();
progressBar.setIndeterminate(true);
int i = 0;
do
{
if(i >= as.length)
break;
try
{
decryptDES1((new StringBuilder()).append(s3).append(ZipUtils.fileSep).append(s6).append(ZipUtils.fileSep).append(as).toString(), (new StringBuilder()).append(s4).append(ZipUtils.fileSep).append(s6).append(ZipUtils.fileSep).append(as[i]).toString(), s);
}
catch(Exception exception1)
{
flag = true;
exception1.printStackTrace();
progressLabel.setText((new StringBuilder()).append("Error in Decrypting with day pwd :\n").append(exception1.getMessage()).toString());
JOptionPane.showMessageDialog(this, "Error in Day Password Decryption");
jbOk.setEnabled(true);
setCursor(null);
try
{
while(thread.getState() != Thread.State.TERMINATED)
try
{
Thread.sleep(1L);
thread = null;
}
catch(InterruptedException interruptedexception1)
{
flag = true;
}
}
catch(NullPointerException nullpointerexception1)
{
flag = true;
}
break;
}
ZipUtils.unZipFiles((new StringBuilder()).append(s4).append(ZipUtils.fileSep).append(s6).toString(), (new StringBuilder()).append(s5).append(ZipUtils.fileSep).append(s6).toString());
i++;
} while(true);
public void decryptDES1(String s, String s1, String s2)
throws IOException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, InvalidKeySpecException, InvalidAlgorithmParameterException, NoSuchPaddingException
{
BufferedInputStream bufferedinputstream = new BufferedInputStream(new FileInputStream(s));
byte abyte0[] = new byte[bufferedinputstream.available()];
bufferedinputstream.read(abyte0);
Cipher cipher = RSAEncryptUtil.getDesDecodeCipher(salt, s2);
byte abyte1[] = cipher.doFinal(abyte0);
bufferedinputstream.close();
if(s1 != "")
{
FileOutputStream fileoutputstream = new FileOutputStream(s1);
fileoutputstream.write(abyte1);
fileoutputstream.close();
}
}
RSAEncryptUtil.Class Code
public static Cipher getDesDecodeCipher(byte abyte0[], String s)
throws InvalidKeyException, FileNotFoundException, BadPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, InvalidKeySpecException, InvalidAlgorithmParameterException, NoSuchPaddingException, IOException
{
return getDESCipher(abyte0, s, 2);
}
public static Cipher getDesEncodeCipher(byte abyte0[], String s)
throws InvalidKeyException, FileNotFoundException, BadPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, InvalidKeySpecException, InvalidAlgorithmParameterException, NoSuchPaddingException, IOException
{
return getDESCipher(abyte0, s, 1);
}
private static Cipher getDESCipher(byte abyte0[], String s, int i)
throws FileNotFoundException, IOException, BadPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, InvalidKeySpecException, InvalidKeyException, InvalidAlgorithmParameterException, NoSuchPaddingException
{
Cipher cipher = null;
javax.crypto.SecretKey secretkey = null;
PBEParameterSpec pbeparameterspec = new PBEParameterSpec(abyte0, 20);
PBEKeySpec pbekeyspec = new PBEKeySpec(s.toCharArray());
SecretKeyFactory secretkeyfactory = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
secretkey = secretkeyfactory.generateSecret(pbekeyspec);
cipher = Cipher.getInstance("PBEWithMD5AndDES");
cipher.init(i, secretkey, pbeparameterspec);
return cipher;
}