package com.fuyuanshen.common.encrypt.utils;

import com.fuyuanshen.common.core.domain.model.PasswordLoginBody;

/**
 * 登录测试
 *
 * @author: 默苍璃
 * @date: 2025-06-3014:29
 */
public class EncryptUtilsTest {

    public static void main(String[] args) {
        // System.out.println(EncryptUtils.encryptByBase64("123456"));

        System.out.println(EncryptUtils.encryptByBase64("1234567890abcdef"));

        String g = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKoR8mX0rGKLqzcWmOzbfj64K8ZIgOdHnzkXSOVOZbFu/TJhZ7rFAN+eaGkl3C4buccQd/EjEsj9ir7ijT7h96MCAwEAAQ==";
        String s = "MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAqhHyZfSsYourNxaY7Nt+PrgrxkiA50efORdI5U5lsW79MmFnusUA355oaSXcLhu5xxB38SMSyP2KvuKNPuH3owIDAQABAkAfoiLyL+Z4lf4Myxk6xUDgLaWGximj20CUf+5BKKnlrK+Ed8gAkM0HqoTt2UZwA5E2MzS4EI2gjfQhz5X28uqxAiEA3wNFxfrCZlSZHb0gn2zDpWowcSxQAgiCstxGUoOqlW8CIQDDOerGKH5OmCJ4Z21v+F25WaHYPxCFMvwxpcw99EcvDQIgIdhDTIqD2jfYjPTY8Jj3EDGPbH2HHuffvflECt3Ek60CIQCFRlCkHpi7hthhYhovyloRYsM+IS9h/0BzlEAuO0ktMQIgSPT3aFAgJYwKpqRYKlLDVcflZFCKY7u3UP8iWi1Qw0Y=";


        String s1 = EncryptUtils.encryptByRsa("MTIzNDU2Nzg5MGFiY2RlZg==", g);
        System.out.println(s1);
        String s2 = EncryptUtils.decryptByRsa("jJPaW7hgFXD/gjdkrfBOEUdXpPZnQg/LZUASoOJAOLU/XRVXO/5666CzyALjw7neK1ujvRuys4MdKCvr9cRARw==", s);
        System.out.println(s2);

        String s3 = EncryptUtils.decryptByBase64(s2);
        System.out.println(s3);

        String s4 = EncryptUtils.encryptByAes("123456", s3);
        System.out.println(s4);

        String s5 = EncryptUtils.decryptByAes(s4, s3);
        System.out.println(s5);


        // 1. 构造 LoginBody 对象
        PasswordLoginBody loginBody = new PasswordLoginBody();
        loginBody.setClientId("e5cd7e4891bf95d1d19206ce24a7b32e");
        loginBody.setGrantType("password");
        loginBody.setTenantId("894078");
        loginBody.setCode("0");
        loginBody.setUuid("1c285b27f516486f9535face77023aeb");
        // loginBody.setUsername("admin");
        // loginBody.setPassword("admin123");
        loginBody.setUsername("dyf");
        loginBody.setPassword("123456");

        // 2. 使用更清晰的方式拼接 JSON 字符串
        String jsonLoginBody = String.format(
                "{"
                        + "\"clientId\":\"%s\","
                        + "\"grantType\":\"%s\","
                        + "\"tenantId\":\"%s\","
                        + "\"code\":\"%s\","
                        + "\"uuid\":\"%s\","
                        + "\"username\":\"%s\","
                        + "\"password\":\"%s\""
                        + "}",
                loginBody.getClientId(),
                loginBody.getGrantType(),
                loginBody.getTenantId(),
                loginBody.getCode(),
                loginBody.getUuid(),
                loginBody.getUsername(),
                loginBody.getPassword()
        );


        String S5 = EncryptUtils.encryptByAes(jsonLoginBody, s3);
        System.out.println(S5);

        String S6 = EncryptUtils.decryptByAes(S5, s3);
        System.out.println(S6);

    }

}
