This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Security and the fly likes Unable to decrypt the encrypted message Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Security
Bookmark "Unable to decrypt the encrypted message" Watch "Unable to decrypt the encrypted message" New topic

Unable to decrypt the encrypted message

Swapna latha
Ranch Hand

Joined: Dec 18, 2011
Posts: 70
Hi ,

I have written encryption and decryption program using AES in I am encrypting the id (primary key) and emai id (string) & sending a mail to the user. the id and email are encrypted and a link is send to the mail id in with encrypted id and email. When the user clicks that link he should be able to see the message what he has typed. But during decryption i am getting "javax.crypto.IllegalBlockSizeException: Input length must be multiple of 16"

Please help me understand where I am going wrong in my code:


swapna kori
Richard Tookey
Ranch Hand

Joined: Aug 27, 2012
Posts: 1035

I can see nothing obvious but somewhere in the chain of things your ciphertext is becoming corrupted.

Note - using

defaults the block mode and padding to

and ECB is generally considered insecure since it allows forgery of ciphertext by splicing parts of different ciphertext.

<edit> I have just seen one possibility - your split() on '=' may be picking up the '=' at the end of a Base64 encoding! The offending code is

so your ciphertext may be truncated!
Consider Paul's rocket mass heater.
subject: Unable to decrypt the encrypted message
Similar Threads
decryption and padding in java cryptography
[ ParseError at [row,col]:[1,175]
AES encryption
Sorry about spamming the board with questions! But here another question about PBE encryption
What broke between 1.4 and 1.6 for decryption?