| 12345678910111213141516 |
- package tools;
- import org.springframework.security.crypto.bcrypt.BCrypt;
- /**
- * 验证 Java BCrypt 能否校验 PHP password_hash() 生成的 $2y$ 口令。
- * 用法: java -cp "target/classes;<m2>/spring-security-crypto-*.jar" BcryptCheck.java <明文> <hash>
- */
- public class BcryptCheck {
- public static void main(String[] args) {
- String raw = args[0];
- String hash = args[1];
- System.out.println("hash prefix: " + hash.substring(0, 7));
- System.out.println("result: " + BCrypt.checkpw(raw, hash));
- }
- }
|