i have a problem in decrypting a message on the client side, as it shows the BadPaddingException:Final block is not padded properly. i am using DES, and using getInputStream and getOutputStream for sending and receiving data, first reading the length of the bytes n then byte itself. problem is, it works properly at first time, even for two clients but next time it shows exception.
On your way in you may have missed that we have a policy on screen names here at JavaRanch. Basically, it must consist of a first name, a space, and a last name, and not be obviously fictitious. Since yours does not conform with it, please take a moment to change it, which you can do right here.
I had a similar problem just the other day. What I noticed is I was encrypting 16 bytes of data and the result was 32 bytes, but when I was sending the data I assumed I had 16 bytes. This essentially sheared the Padding bytes off. Print the length of the input byte array and then the length of the output byte array and compare.
I hope this is your issue also Good luck
PS. I also receive this error when I didn�t have the correct policy files!
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com