Java bcrypt example
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.unasat</groupId>
<artifactId>encrypt</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.mindrot/jbcrypt -->
<dependency>
<groupId>org.mindrot</groupId>
<artifactId>jbcrypt</artifactId>
<version>0.4</version>
</dependency>
</dependencies>
</project>
import org.mindrot.jbcrypt.BCrypt;
public class App {
public static void main(String[] args) {
String inputpassword = "mitchel1";
String storedpassword = "mitchel";
String hashedStoredPassword = BCrypt.hashpw(storedpassword, BCrypt.gensalt());
boolean isValid = BCrypt.checkpw(inputpassword, hashedStoredPassword);
System.out.println(isValid);
}
}