package cn.novalon.manage.sys.util;

import org.junit.jupiter.api.Test;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

public class PasswordHashGenerator {
    
    @Test
    public void generatePasswordHash() {
        PasswordEncoder passwordEncoder = new BCryptPasswordEncoder(12);
        
        String password = "Test@123";
        String hash = passwordEncoder.encode(password);
        
        System.out.println("========================================");
        System.out.println("密码: " + password);
        System.out.println("哈希: " + hash);
        System.out.println("========================================");
        
        boolean matches = passwordEncoder.matches(password, hash);
        System.out.println("验证结果: " + matches);
        
        String hash2b = "$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/X4.VTtYA/7.J6LlZy";
        boolean matches2b = passwordEncoder.matches(password, hash2b);
        System.out.println("验证$2b$哈希结果: " + matches2b);
    }
}
