package com.hzya.frame.ttxofs;

import cn.hutool.core.util.StrUtil;
import org.apache.commons.codec.digest.DigestUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 通天晓OFS，认证授权加密类
 *
 * @Author：liuyang
 * @Package：com.hzya.frame.ttxofs
 * @Project：kangarooDataCenterV3
 * @name：HexUtil
 * @Date：2024/7/29 14:22
 * @Filename：HexUtil
 */
public class OfsHexUtil {

    Logger logger = LoggerFactory.getLogger(OfsHexUtil.class);

    /**
     * 签名加密
     *
     * @author liuyang
     */
    public String sign(String api, String data, String format, String appKey, String v, String secret, String timestamp) {
//        String str = "${secret}api${api?:''}appKey${appKey?:''}data${data?:''}format${format?:''}timestamp${timestamp?:''}v${v?:''}${secret}";
        String api2appKey1data4format5timestamp6v3 = StrUtil.format("{}api{}appKey{}data{}format{}timestamp{}v{}{}", secret, api, appKey, data, format, timestamp, v, secret);

        logger.info("sign str:" + api2appKey1data4format5timestamp6v3);
        String s = DigestUtils.md5Hex(api2appKey1data4format5timestamp6v3);
        logger.info("local sign:" + s);
        return s;
    }
}