Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to decrypt the encrypted message

 
Swapna latha
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic