I am developing a web application using MySQL and Java Persistence API on Netbeans. The application requires a user to create an account to use and I am trying to encrypt the password before storing into database. The issue is that in my SQL script, I set the user account table that stores the password a string with a size limit of 256 and auto-generated the JPA entity classes. If I stored the password normally, this doesn't create an issue, but the problem becomes whenever I tried to encrypt the password. This is what I originally had:
import org.netbeans.lib.uihandler.PasswdEncryption;
public void encryptPassword(String password)
{
String encryptedPassword = PasswdEncryption.encrypt(password);
storeIntoDatabase(password);
}
However, whenever I tried to create a new account, I receive a EJBExcepton
which was caused by a javax.ConstraintViolationException
.
What I found was that the PasswdEncryption.encrypt
was creating a string size greater than 256 which I believe was causing the exception. I first tried modifying my original SQL script to increase the password entry size and ran it, but I still get the same issue because the entity class constraint is still 256. So my question is
- Is there a way to change the constraints without having to auto-generate again?
- Or create an encryption string with a size of 256 or less?