package com.sqx;

import com.google.gson.Gson;
import com.sqx.modules.errand.entity.TransferRecordEntity;
import com.sqx.modules.riderStation.entity.RiderStation;
import icu.xuyijie.secureapi.cipher.CipherAlgorithmEnum;
import icu.xuyijie.secureapi.cipher.CipherUtils;

/**
 * @author : codingliang
 * @date : 2024-08-07 11:01
 */
public class SecureApiTest {
    public static void main(String[] args) {
        test2();
    }

    public static void test2() {
        CipherUtils cipherUtils = new CipherUtils(CipherAlgorithmEnum.AES_CBC_PKCS5);

        // 生成 key
        // String key = cipherUtils.getRandomSecreteKey();
        // // 生成偏移量（CBC模式需要，ECB模式不需要）
        // String iv = cipherUtils.getRandomIv();
        //
        // System.out.println(key + " " + iv);

        // 生成 key
        String key = "oURKtBcNU6axnNoebKkuPqkCn6ivhE9qbg9FpeNnfpo=";
        // 生成偏移量（CBC模式需要，ECB模式不需要）
        String iv = "eW1xeThJSkprcEZUTGh1Ng==";

        String content = "{\"msg\":\"success\",\"code\":0,\"data\":{\"id\":579,\"userId\":2049,\"money\":1275.39}}";
        String encrypt = cipherUtils.encrypt(content, key, iv);
        System.out.println(encrypt);

        String decrypt = cipherUtils.decrypt("9VpteiNMuNImeaAxLv5NiJcPB5Y8bueaf2v6IGVR5Quv5S0Xyqg8RjCZqZAnQ6X6rGGt9Q8-PfcUXsFr-6l0-NKET9ttEn9Kos_i8qzGj1g=", key, iv);
        System.out.println(decrypt);
    }

    public static void test1() {
        CipherUtils cipherUtils = new CipherUtils(CipherAlgorithmEnum.AES_CBC_PKCS5, false);

        // 生成 key
        String key = "87OGRxGq86S9QO6HJSe78dK0CpuSFVz1TkhnkM/MjE0=";
        // 生成偏移量（CBC模式需要，ECB模式不需要）
        String iv = "UjNyWWxLOWxKTEgzNFFwZw==";

        String content = "{\"msg\":\"success\",\"code\":0,\"data\":{\"id\":579,\"userId\":2049,\"money\":1275.39}}";
        String encrypt = cipherUtils.encrypt(content, key, iv);
        System.out.println(encrypt);

        String decrypt = cipherUtils.decrypt(encrypt, key, iv);
        System.out.println(decrypt);
    }
    // dzUjvlKSwM2V3gg_l_dvGFKdJF84W9cBWQxXKM7NqzMNRAYdEsiF5DJ60iAzNKeDWgVRjR5X2-mqdlVVdEJ5BLfE3gA2lzWn73mnvHNq1R4=
    // dzUjvlKSwM2V3gg_l_dvGFKdJF84W9cBWQxXKM7NqzMNRAYdEsiF5DJ60iAzNKeDWgVRjR5X2-mqdlVVdEJ5BLfE3gA2lzWn73mnvHNq1R4=
}
