BCrypt加密
<dependency>
<groupId>org.mindrot</groupId>
<artifactId>jbcrypt</artifactId>
<version>0.4</version>
</dependency>
public static void main(String[] args) throws IOException, URISyntaxException {
String password = "1234846asdasd";
//多加密几次验证是否每次生成的密文都不一样
for (int i = 0; i < 5; i++) {
String pwt = BCrypt.hashpw(password, BCrypt.gensalt());//加密
System.out.println(pwt);
System.out.println(BCrypt.checkpw(password, pwt));//验证明文密码和密文密码是否对应
}
}
执行结果: