0

I use Hibernate annotation to encrypt password

@ColumnTransformer(write = "crypt(?, gen_salt(...))")
private String password;

But after updating the entity I see in logs that password re-generated.

 password=crypt('$2a$...

How to prevent this field from another encryption while saving the object?

Daria Bulanova
  • 547
  • 1
  • 5
  • 16

2 Answers2

1

Two possible solutions here, my guess is you should go for the second:

Either you need the clear password for some reason, and then you should use a "decrypt" statement on table read, see example 73 in section 2.3.19.

Or you only need to check if the user has sent the right password, and should use a hash function and not encryption. See the difference between hash and encryption, and when to use each.

Lou_is
  • 259
  • 3
  • 11
0

Use that configuration

@Column(name = "password", nullable = false, updatable = false)

Daria Bulanova
  • 547
  • 1
  • 5
  • 16