1. 程式人生 > >spring-security隨即鹽加密

spring-security隨即鹽加密

示例demo

 

public static void main(String[] args) {
    String password = new BCryptPasswordEncoder().encode("123456789");
    String password2 = new BCryptPasswordEncoder().encode("123456789");
    System.out.println(password);
    System.out.println(password2);
    boolean flag = new BCryptPasswordEncoder().matches("123456789",password2);
    System.out.println(flag);
}

 

參考api地址   https://docs.spring.io/spring-security/site/docs/4.0.4.RELEASE/apidocs/org/springframework/security/crypto/bcrypt/BCryptPasswordEncoder.html