Get your CodeRanch badge!*
The moose likes Security and the fly likes BadPaddingException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » Security
Bookmark "BadPaddingException" Watch "BadPaddingException" New topic


Kristof Camelbeke
Ranch Hand

Joined: Nov 28, 2001
Posts: 97

I want to store a user password encrypted in the database.
I've created a class based on an example using JCE.. Here are some code extracts :

It works fine in my junit test which encrypts a given value and decrypts it to it's original.

The problem arrives when I save the encrypted password in the database (oracle). When I try to retrieve the encrypted String and try to decrypt it I receive the following Exception :

The column in the database is of type varchar2 and has a length of 255.
I think it has something to do with the storage in the database since I can do the encryption/decryption in a unit test.

Any help is highly appreciated...


Ulf Dittmer

Joined: Mar 22, 2005
Posts: 39577
Are the database and the database connection running in UTF-8 mode as well?

Ping & DNS - updated with new look and Ping home screen widget
I agree. Here's the link:
subject: BadPaddingException
Similar Threads
Decryption inconsistencies on different platforms
How to hide key in client?
Length of Encrypted String Longer than Original String... Help
Problem Urgent: Crypto using jsp - javabean
Need help in password Encryption and Decryption