I am using hibernate annotation @ColumnTransformer to make use of MySQL data encryption, however, I don't want (actually I can not) hard code the password into the code, instead, I want to load the password say from application.properties file, sample as below:
@NotBlank
@Column(name = "phone_numbers", columnDefinition = "LONGBLOB")
@ColumnTransformer(
read="AES_DECRYPT(phone_numbers, '${mms.encryption.key}')",
write="AES_ENCRYPT(?, '${mms.encryption.key}')")
private String phoneNumbers;```
The mms.encryption.key is an entry in application.properties
mms.encryption.key=mypassword
But seems this one won't work. What is the best way to do this?
I found a similar post here, but I am not sure if someone has a better solution in year 2018.