Search code examples
javaspring-bootencryptionspring-cloud-config

How to encrypt value for {cipher} in spring boot?


I know how to use Jasypt

But I've learned that there are alternative in spring stack using cipher:

security.user.password: '{cipher}56e611ce4a99ffd99908d2c9aa1461d831722812e4370a5b6900b7ea680ae914'  

https://stackoverflow.com/a/28434892/2674303

But I have no idea:

  1. How can I encrypt my password "superSecretPassword" ? (in case of Jasypt I used this service: https://www.devglan.com/online-tools/jasypt-online-encryption-decryption)
  2. Which algorithm will be used under the hood ? Could it be changed ?
  3. What dependencies are required ? P.S. I don't use spring cloud in my project

Solution

  • You need to download the Spring Boot CLI and add the Spring Cloud CLI. You then can run the spring encrypt and spring decrypt. These pages will instruct you on how to install and how to run these commands.

    I don't believe you can change the encryption algorithm and I haven't found what algorithm is used.