package com.haha.admin;

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

/**
 * 密码加密工具测试类
 * 用于生成BCrypt加密后的密码
 */
public class PasswordEncoderTest {
    
    @Test
    public void generatePassword() {
        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
        
        // 生成密码: admin123
        String password = "admin123";
        String encodedPassword = encoder.encode(password);
        
        System.out.println("原始密码: " + password);
        System.out.println("BCrypt加密后: " + encodedPassword);
        System.out.println();
        
        // 生成SQL语句
        System.out.println("-- 管理员表SQL");
        System.out.println("-- 密码: admin123");
        System.out.println("UPDATE t_admin SET password = '" + encodedPassword + "' WHERE username = 'admin';");
        System.out.println("UPDATE t_admin SET password = '" + encodedPassword + "' WHERE username = 'operator';");
        System.out.println("UPDATE t_admin SET password = '" + encodedPassword + "' WHERE username = 'service';");
        System.out.println();
        
        // 验证密码
        boolean matches = encoder.matches(password, encodedPassword);
        System.out.println("密码验证结果: " + matches);
    }
}
