Is ENC function necessary before encrypted value in .properties file?

13.2k views Asked by At

As a general rule, jasypt expects encrypted configuration parameters to appear surrounded by "ENC(...)".

For example, in appConfig.properties file I have following properties:

databaseurl = sampleurl username = username password = password

If I encrypt my password; if I get 'G6N718UuyPE5bHyWKyuLQSm02auQPUtm' as encrypted value and surrounded this value with ENC("") function in .properties file. password=ENC(G6N718UuyPE5bHyWKyuLQSm02auQPUtm)

How to decrypt this value? Should I code such a way that only content of the ENC function is taken and decrypted? or there is any other way.

[1]: http://www.jasypt.org/encrypting-configuration.html I am using this link as reference.

1

There are 1 answers

0
Andy On

If you use the Jasypt class EncryptableProperties, this is handled for you without any additional work. If you want to use a different method to decrypt the data, you'll need to strip ENC( and ) from the string, decode the Base64 contents to raw bytes, and then use a Cipher which is configured with the same encryption key as derived by Jasypt.