BcryptCheck2.java 512 B

123456789101112
  1. import org.springframework.security.crypto.bcrypt.BCrypt;
  2. /** 验证 Java BCrypt 能否校验 PHP password_hash() 生成的 $2y$ 口令 */
  3. public class BcryptCheck {
  4. public static void main(String[] args) {
  5. String raw = args[0];
  6. String hash = args[1];
  7. System.out.println("hash prefix : " + hash.substring(0, 7));
  8. System.out.println("正确密码 : " + BCrypt.checkpw(raw, hash));
  9. System.out.println("错误密码 : " + BCrypt.checkpw(raw + "x", hash));
  10. }
  11. }