package cn.unitid.matrix.pkiservice.test.ces;

import cn.unitid.matrix.pkiservice.sdk.ApiException;
import cn.unitid.matrix.pkiservice.sdk.DefaultPkiClient;
import cn.unitid.matrix.pkiservice.sdk.PkiClient;
import cn.unitid.matrix.pkiservice.sdk.ces.request.DigestGenerateRequest;
import cn.unitid.matrix.pkiservice.sdk.ces.response.DigestGenerateResponse;
import cn.unitid.matrix.pkiservice.sdk.consts.DataType;
import cn.unitid.matrix.pkiservice.sdk.consts.DigestAlgorithmType;

/**
 * @author Shy
 * @className DigestGenerateTest
 * @description 摘要生成测试
 * @date 2022/8/9 10:22
 **/
public class DigestGenerateTest {

    public static void main(String[] args) {
        // 提供的URL
        String url = "http://localhost:20501";

        // 您的appKey
        String appKey = "4WLraMuAwd";

        // 您的appSecret
        String appSecret = "PDiBmR2u0sIlOBCHdCzKgaGFBxadSPbP";

        //原客户端
        PkiClient pkiClient = new DefaultPkiClient(url,appKey,appSecret);

        DigestGenerateRequest request= new DigestGenerateRequest();
        request.setData("Shy1234");
        request.setDataType(DataType.ORIGINAL);
        request.setDigestDataType(DataType.BASE64);
        request.setDigestAlgorithm(DigestAlgorithmType.SM3);
        request.setAccelerate(false);

        try {
            DigestGenerateResponse response = pkiClient.execute(request);
            if (response.isSuccess()) {
                System.out.println("成功：" + response.getResult());
            } else {
                System.out.println("失败：" + response.getBody());
            }
        } catch (ApiException e) {
            e.printStackTrace();
        }


    }
}
