Java - BCrypt 加解密

ROR devise encrypted_password 加密功能 改為JAVA驗證

Gradle

compile group: 'org.mindrot', name: 'jbcrypt', version: '0.4'

Maven

<dependency>
   <groupId>org.mindrot</groupId>
   <artifactId>jbcrypt</artifactId>
   <version>0.4</version>
</dependency>

Java

// Hash a password for the first time
String password = "111111";
// gensalt's log_rounds parameter determines the complexity
// the work factor is 2**log_rounds, and the default is 10
String hashed = BCrypt.hashpw(password, BCrypt.gensalt(11));
System.out.println(hashed);
Boolean b  = BCrypt.checkpw(password, hashed );
System.out.println(b);

output

$2a$11$YmllXsSDIaa28CwrF.2lN.gEehlOUhutq7vD7IOnnvDcgeRv.Z51a
true

「BCrypt」的圖片搜尋結果