Hi,
I'm in trouble to decrypt the data which I got from servlet.
MY code is
URL url = new URL("http://localhost:8084/DataService/GetData?ChartName=preferences");
URLConnection yc = url.openConnection();
InputStream inputStream = yc.getInputStream();
byte[] data = new byte[2125];
inputStream.read(data);
inputStream.close();
DESKeySpec spec = new DESKeySpec(keyBytes);
SecretKeyFactory instance = SecretKeyFactory.getInstance("DES");
SecretKey key = instance.generateSecret(spec);
Cipher cipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, key);
byte[] doFinal = cipher.doFinal(data);
System.out.println(new String(doFinal));
and I'm getting the following error
javax.crypto.IllegalBlockSizeException: Input length must be multiple of 8 when decrypting with padded cipher
at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
at com.sun.crypto.provider.DESCipher.engineDoFinal(DashoA13*..)
at javax.crypto.Cipher.doFinal(DashoA13*..)
at cbcdemo.Main.main(Main.java:86)
thanks in advance