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!

javax.crypto.BadPaddingException

843810Mar 17 2004 — edited Mar 19 2004
Hi!

I have an exception when I am decrypting a SealedObject:
javax.crypto.BadPaddingException: Given final block not properly padded
I encrypt my SealedObject using a DES key. This key is saved as a variable and passed to the decryption method and used to decrypt the SealedObject. This is the code for it
desKey = keyGen.generateKey();

public Vote decryptVote(SealedObject so, desKey)
{
Cipher decipher;
Vote vote = null;
try {
   decipher = Cipher.getInstance("DES");
   decipher.init(Cipher.DECRYPT_MODE, desKey);
   vote = (Vote) so.getObject(decipher);
} catch (NoSuchPaddingException e) {
  System.out.println("");
  e.printStackTrace();
I have used my IDE debugger and looked at my code and I can see that the data in my Key is the dame at encryption time and deryption time.
I am new to cryptography and I would be grateful tp even find out what a Bad Padding exception is!

Thanks for your help,

Chris
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 16 2004
Added on Mar 17 2004
33 comments
1,480 views