springsecurity Password Md5+salt configuration

Source: Internet
Author: User
Tags md5 encryption

The password is MD5 encrypted with a salt value.

For example Username:name Password:pass salt to username

The plaintext password is pass{name} parentheses for the salt corresponding to the username, and then the plaintext password is encrypted


The springsecurity is configured as follows

 <authentication-manager  alias= "AuthenticationManager"  >     <authentication-provider ref= "Authenticationprovider" >  </authentication-provider>  </authentication-manager>       <beans:bean id= " Authenticationprovider " class=" Org.springframework.security.authentication.dao.DaoAuthenticationProvider " >      <beans:property name= "Userdetailsservice"  ref= " Myuserdetailservice " />      <beans:property name=" Passwordencoder " ref=" Passwordencoder "/>     <beans:property name=" Saltsource " ref=" Saltsource "/>   </beans:bean>    <beans: Bean id= "Passwordencoder"   class= " Org.springframework.security.authentication.encoding.Md5PasswordEncoder "/><beans:bean id=" SaltsouRce " class=" Org.springframework.security.authentication.dao.reflec tionsaltsource ">     <beans:property name= "Userpropertytouse"  value= "username"/></beans:bean>


Add Passwordencoder and Saltsource two properties to the Authenticationprovider configuration

This configuration is over.


At the same time, Springsecurity provides the Md5passwordencoder class to implement MD5 encryption

Md5passwordencoder MD5 = new Md5passwordencoder (); String result = Md5.encodepassword ("User", "user"); SYSTEM.OUT.PRINTLN (result);

Md5.encodepassword two parameters, the previous one is password, the latter is the salt salt value


At the same time, website http://md5jiami.51240.com/also provides the function of online encryption





This article is from the "Bulajunjun" blog, make sure to keep this source http://5148737.blog.51cto.com/5138737/1615981

springsecurity Password Md5+salt configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.