aspose file tools*
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
JavaRanch » Java Forums » Engineering » Security
Bookmark "Unable to decrypt the encrypted message" Watch "Unable to decrypt the encrypted message" New topic
Author

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 ContactAction.java. 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:

ContactAction.java







thanks

swapna kori
Richard Tookey
Ranch Hand

Joined: Aug 27, 2012
Posts: 1053
    
  10

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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to decrypt the encrypted message