aspose file tools*
The moose likes Java in General and the fly likes javax.crypto.IllegalBlockSizeException:  When Decoding an Input String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "javax.crypto.IllegalBlockSizeException:  When Decoding an Input String" Watch "javax.crypto.IllegalBlockSizeException:  When Decoding an Input String" New topic
Author

javax.crypto.IllegalBlockSizeException: When Decoding an Input String

Tom Walsh
Greenhorn

Joined: Jan 17, 2011
Posts: 4
Hello, I have been given the following class for encrypting and decrypting password strings. I can encrypt ok but I receive errors when I try to decrypt. The error is as follows

EncryptionHelper.encrypt...byte array length: 18EncryptionHelper.encrypt...string interpretation: [B@b179c3 Encrypt len = 44 EncryptionHelper.encrypt...return value: [B@67ac19 String decoded = [B@53ba3d Lent=5 testt Controller.main...exception, illegal block size: javax.crypto.IllegalBlockSizeException: Input length must be multiple of 16 when decrypting with padded cipher
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.SunJCE_f.b(DashoA13*..)
at com.sun.crypto.provider.AESCipher.engineDoFinal(DashoA13*..)
at javax.crypto.Cipher.doFinal(DashoA13*..)
at com.avaya.utility.updater.EncryptionHelper.decrypt(EncryptionHelper.java:60)
at com.avaya.utility.updater.Controller.main(Controller.java:90)

My class is as follows



The error occurs at the following line "byte[] recoveredBytes = cipher.doFinal(encryptionBytes);"

How can I confirm that "byte[] encryptionBytes" will be a multiple of 16?

Thanks!

 
Don't get me started about those stupid light bulbs.
 
subject: javax.crypto.IllegalBlockSizeException: When Decoding an Input String