Problems decrypting using "DES/ECB/PKCS5Padding"
Hi,
I am using "DES/ECB/PKCS5Padding"
// Key is stored in file
FileInputStream fin = new FileInputStream("CrypterKey.ser");
ObjectInputStream oin = new ObjectInputStream(fin);
Key aKey = (Key) oin.readObject();
keys.put("FMCrypterKey.ser", aKey);
// Initialize key and cipher on first access
cipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
//decrypt the input string.
cipher.init(Cipher.DECRYPT_MODE, aKey);
BASE64Decoder decoder = new BASE64Decoder();
byte[] raw = decoder.decodeBuffer(cryptText);
byte[] stringBytes = cipher.doFinal(raw);
String result = new String(stringBytes, "UTF8");
It is encrypted using Base64. The code works fine in many instances & in Windows & Unix servers. Only one of the batch running on production unix server throws the following exception:
javax.crypto.IllegalBlockSizeException: Input length must be multiple of 8 when decrypting with padded cipher
This happens to all the decryption attempts in that particular batch process in production.
What are the environment related issues or other issues that can cause this exception.
Thanks,
Sudhindra

