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