Spring Security : Encrypt password

Manish Kumar

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.

Jeevan Patil

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.

edited at
0

Comments

0 comments
Login to comment

Related

How to use Spring security without password encoding?

Encrypt password fields in mongodb

Remove "Using default security password" on Spring Boot

Username Password Authentication in Spring Security

Spring Security 5.2 Password Flow

BCrypt: Empty Encoded Password with Spring Security

Java spring boot encrypt admin password before storing it in database?

Spring Boot/ Spring Security, login form, password checking

why spring security gives empty password to password encoder?

Read username/password from a file in Spring Security

Spring Security - Conceptual question around generated security password

Password encrypt and decrypt using Spring-security

Spring Security - Get clear password on authentication and re-encrypt them

Password encoding and decoding using Spring Security, Spring Boot and MongoDB

How to encrypt password using Python Flask-Security using bcrypt?

Spring Boot Rest Security Basic Auth Password Encoder does not encrypt password on login

Laravel authentication with encrypt password

Spring Security BASIC auth - matching password hash

Encrypt alfresco password

flask-security encrypt_password('mypassword') varies every time when i reload the page

Recover username and password with spring security

Spring security_Password Encryption

spring security encode password with bcrypt algorithm

Spring Security force logout when password change

Encrypt Password

Spring security: get password in UserDetailsServiceMethod

Spring Security Basic Auth Password Rotation Issue

Password is not getting encoded in spring security

Is there a way to configure password encoder for default spring security password