I am using spring 3.2.5. Righ now i am hashing password using
MessageDigest messageDigest = MessageDigest.getInstance("SHA-512");
messageDigest.update(password.getBytes("UTF-8"));
byte[] digestBytes = messageDigest.digest();
I want to secure password using methods provided by spring. I searched internet and most of the post are very old. So any example will be fine.
You can use org.springframework.security.crypto.password.StandardPasswordEncoder
class. It is a lot less hassle, you don't have to worry about salt and iterations - the details are completely encapsulated within the encoder.
<!-- password encoder -->
<beans:bean id="encoder" class="org.springframework.security.crypto.password.StandardPasswordEncoder" />
<!-- This is the authentication manager -->
<authentication-manager>
<authentication-provider user-service-ref="authService">
<password-encoder ref="encoder" />
</authentication-provider>
</authentication-manager>
Visit this site to know more.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments