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

[1221 byte] By [sbhargava] at [2007-11-27 5:56:06]
# 1
I would suggest that your cryptText content has got corrupted or you are using a different key for decryption than is used for encryption.
sabre150a at 2007-7-12 16:26:03 > top of Java-index,Security,Cryptography...
# 2
I did verify the exact crypttext & the key file from production by ftping it back from the server. it works fine in standalone mode. Also in production all other batches using this crypt text & the key file are working fine.Thanks,Sudhindra
sbhargava at 2007-7-12 16:26:03 > top of Java-index,Security,Cryptography...