title: Password encrypt and decrypt using Spring-security
body: <p>Preface: I have a JAR which is developed by making use of <code>spring-boot</code> (maven project). Then, I will access my JAR folder and run the below command to execute it:</p>
  
  <pre><code>java -server -jar ${jarName}
  --spring.config.location=classpath:config.properties
  </code></pre>
  
  <p>So my JAR reads the <code>{key, value}</code> pairs from the properties file and executes the code accordingly. This is working with no issues, but I have few a properties in my <code>config.properties</code> file which has DB details to connect to an Oracle database directly. It also has my application super-admin username &amp; password. </p>
  
  <p>I don't want to push this code to <code>bit-bucket/stash/git</code>, since it has all my passwords stored in it.</p>
  
  <p><strong>Work Around</strong>: I can push my code to <code>git/stash</code> with empty passwords and then run the below command to inject the properties file through <code>--spring.config.location</code> command as follows </p>
  
  <pre><code>java -server -jar ${jarName}
  --spring.config.location=./config.properties
  </code></pre>
  
  <p><strong>Question:</strong> How to encrypt and decrypt a String/password in spring applications?</p>
  
  <p>I want to store the password in the properties file which is in encrypted format and then decrypt it through my code and connect to the Oracle database &amp; to my application.</p>