Spring Password Encoding

Password Encoding

  • A hash in with the spring-security-core jar
          String s = "test";
          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
 The 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

评论

此博客中的热门博文

XML, XSL, HTML

Input in element.eleme.io

Data URI是由RFC 2397 ACE