I have to decrypt a frame on my server. Encrypted frame comes from client device through GPRS on socket.Encryption is done with TripleDes and
The main issue with your code is that you are decrypting using a default of PKCS5Padding. "TripleDES"
will result in "TripleDES/ECB/PKCS5Padding"
internally. This is as it is implemented in the Sun JCE provider; most other providers copy this default.
It seems you are expecting zero padding, which means you should use "DESede/ECB/NoPadding"
instead. After that you can use an external function to calculate the plain text size (removing zero padding may remove zero valued plain text at the end if you are not careful).
Other issues:
"0"
, which is probably wrongI've indicated "ECB"
because I don't know the actual mode used. You could amend your question with the right mode and padding algorithm if you can find out. You might want to try CBC mode as well if ECB does not work.
Note that ECB mode is not safe to use except for very specific circumstances. Using CBC with a randomized IV is a minimal requirement.