import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; public class PasswordChecker { public static void main(String[] args) { BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(); String hash = "$2a$10$N.zmdr9k7uOCQb376NoUnuTJ8iAt6Z5EHsM8lE9lBOsl7iKTVEFDi"; // 测试不同的密码 String[] passwords = {"demo", "admin", "password", "123456"}; for (String password : passwords) { boolean matches = encoder.matches(password, hash); System.out.println("Password '" + password + "' matches: " + matches); } } }