There is two mistakes you have done in your code
you use DESede
to create the secret key factory in this line
SecretKeyFactory factory = SecretKeyFactory.getInstance("DESede");
but you use the DES
to get the Cipher
object. you have to use DESede
instead
so use this line
encryptCipher = Cipher.getInstance("DESede/CBC/PKCS5Padding");
instead of this line
encryptCipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
use the same algorithm to get decripting cipher
and another one is use a AlgorithmParameterSpec
to init the decrypting cipher.
byte iv[] = encryptCipher.getIV();
IvParameterSpec dps = new IvParameterSpec(iv);
decryptCipher.init(Cipher.DECRYPT_MODE, key, dps);
you can use above code to apply the AlgorithmParameterSpec
to the initialization of cipher