How to Use Password Encoder in Spring Security

By Arvind Rai, December 20, 2013

This page will help you to understand how to use spring security with encoded password. Encoded password is necessary in the application where security is more concern. To add password encoder we need to use the &ltpassword-encoder/&gt inside &ltauthentication-provider&gt. Find more detail on &ltpassword-encoder/&gt.

&ltpassword-encoder/&gt

&ltpassword-encoder/&gt has the attribute hash that can be assigned encoding algorithm. In our example we are using SHA 1 encoding configure the below line to add password encoder.

&ltpassword-encoder hash="sha"/&gt

If we have a user concretepage and password con1234, then we will configure it as

In our example we have used password encoder with database. Use URL http://localhost:8080/SpringSecurity/login to run the example. To understand table schema, go to the link Spring Security Login Example with Database