Spring Password Encoding
Password Encoding
org.springframework.security.authentication.encoding.Md5PasswordEncoder md5e =
new org.springframework.security.authentication.encoding.Md5PasswordEncoder();
System.out.println("md5e.encodePassword(s, null):" +
md5e.encodePassword(s, null));
org.springframework.security.crypto.password.StandardPasswordEncoder SE =
new org.springframework.security.crypto.password.StandardPasswordEncoder();
String stEncode = SE.encode(s);
System.out.println("StandardPasswordEncoder.encode:" + stEncode);
Ref: http://static.springsource.org/spring-security/site/docs/3.1.x/reference/springsecurity-single.html#core-services-password-encoding
- A hash in with the spring-security-core jar
org.springframework.security.authentication.encoding.Md5PasswordEncoder md5e =
new org.springframework.security.authentication.encoding.Md5PasswordEncoder();
System.out.println("md5e.encodePassword(s, null):" +
md5e.encodePassword(s, null));
- A hash with Salt added
StandardPasswordEncoder
in the crypto
package uses a random 8-byte salt, which is
stored in the same field as the password.org.springframework.security.crypto.password.StandardPasswordEncoder SE =
new org.springframework.security.crypto.password.StandardPasswordEncoder();
String stEncode = SE.encode(s);
System.out.println("StandardPasswordEncoder.encode:" + stEncode);
Ref: http://static.springsource.org/spring-security/site/docs/3.1.x/reference/springsecurity-single.html#core-services-password-encoding
评论
发表评论