Home » Java » java – Decrypting the data of column stored using @ColumnTransfer annotation-Exceptionshub

java – Decrypting the data of column stored using @ColumnTransfer annotation-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:

I am working in spring framework. I am inserting the user data in MySQL database using Model. I am storing the user password in encrypted form using the annotation
@ColumnTransformer(read="decrypt(password)",write="encrypt(?)").

But when we are selecting password from database for user validation it is not returning the password after decryption.

Connection connection = connectionService.createConnection();

PreparedStatement statement = connection.prepareStatement("select email,password 
from employee_table");

ResultSet rs = statement.executeQuery();

while (rs.next()) {
   email_list.add(rs.getString("email"));
   password_list.add(rs.getString("password"));
}

Example :

Original Password :qwerty

Encrypted Password : 67qwerty54asj

Actual Output : 67qwerty54asj

Required Output : qwerty

How to&Answers: