Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

BadPaddingException

 
IT
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello-

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
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic