Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem with encryption and decryption method's

843811Apr 28 2008 — edited Apr 30 2008
Hi friends,

I have a very serious problem to encrypt and decrypt data with AES algorithm. My problem is the following:

I found several examples to encrypt and decrypt data with AES. Well, in that point, I proved that examples with a only program, and the encryption run perfectly. Then, I passed the examples code to my aplication, in which I have a java client and a java server. My idea is encrypt the comunication between two parts, to set the channel more sure.

When I encrypt the data in the java client, the encryption is well, but when I want to decrypt that data (I send the data on Internet with socket), sometimes the decryption is well, and other time the server shows me the following message:

javax.crypto.IllegalBlockSizeException: Input length must be multiple of 16 when
decrypting with padded cipher
at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
at com.sun.crypto.provider.AESCipher.engineDoFinal(DashoA13*..)
at javax.crypto.Cipher.doFinal(DashoA13*..)
at AES.desencriptarDatos(AES.java:131)
at AplicacionServidor.main(AplicacionServidor.java:84)

Anyone can help me please? I want to finish this part and I have taken a lot of time with the theme. With other examples that I found on Internet I obtain the same result. Anyone knows the answer to this situation?

Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 28 2008
Added on Apr 28 2008
4 comments
2,250 views