import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; public class TestBCrypt { public static void main(String[] args) { BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(12); String password = "admin123"; String hash = "$2b$12$SFefXlGRFMA0fvxIufpWPuIAl0OPLgRDoCZPThCvjpiJGPYS8yNYy"; System.out.println("测试密码验证:"); System.out.println("密码: " + password); System.out.println("哈希: " + hash); System.out.println("验证结果: " + encoder.matches(password, hash)); } }