Ulf Dittmer wrote:Obviously because there's an exception that
is ignored by the code. You should never put empty catch blocks into your code. At least print the stack trace to where you will see it.
firstEncryption Value : ygGPwCllarWvSH8td55j/w==
javax.crypto.BadPaddingException: Given final block not properly padded
decryption Value : null
java.lang.NullPointerException at DESedeEncryption.desEncryption(DESedeEncryption.java:130)
secondEncryption Value : null
Joined: Mar 22, 2005
Start by working with byte arrays - leave out the base64 stuff.
That is not how 2 key 3DES is computed. Both your encryption and decryption stages use PKCS5 padding so you use PKCS5 padding at each stage. You only need PKCS5 padding for for the first stage of encryption and last stage of decryption. The other stages need no padding.
Note - the best way to perform 3DES with ECB and PKCS5 padding is to use "DESede/ECB/PKCS5Padding" as the Cipher specification and build the 24 bytes (56*3 key bits + 24 parity bits) of the 168 bit key as the concatenation of the first key, the second key and then the first key again.
Note 1 - DES is deprecated in favour of AES.
Note 2 - ECB is not considered secure as it allow forging of ciphertext by splicing ciphertext from two or more other ciphertext.