<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
</dependency>
public class BcryptTest {
public static void main(String[] args) {
//用户密码
String password = "123456";
//密码加密
BCryptPasswordEncoder passwordEncoder=new BCryptPasswordEncoder();
//加密
String newPassword1 = passwordEncoder.encode(password);
System.out.println("加密密码1为:"+newPassword1);
String userInput="123456";
//对比这两个密码是否是同一个密码
boolean matches = passwordEncoder.matches(userInput, newPassword1);
System.out.println("两个密码一致:"+matches);
}
}