jQuery in Action, 3rd edition
The moose likes Security and the fly likes BadPaddingException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Security
Bookmark "BadPaddingException" Watch "BadPaddingException" New topic



Joined: Feb 07, 2007
Posts: 1
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.

please help.
thank you
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965

Welcome to JavaRanch.

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.
Kevin Baker

Joined: Jun 20, 2002
Posts: 10
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 agree. Here's the link: http://aspose.com/file-tools
subject: BadPaddingException
It's not a secret anymore!