package com.m2pool.lease.utils;

import java.math.BigInteger;

/**
 * @Description 支付工具类
 * @Date 2025/8/8 11:05
 * @Author yyb
 */
public class JnaUtils {

    private static final String key = "m2pool";

    /**
     * 获取签名秘钥
     * @param timeStamp
     * @return
     */
    public static String getSign(Long timeStamp){
        String inputStr = "1758610297";
        // 将字符串转换为 BigInteger 对象，指定基数为 10
        BigInteger decimalValue = new BigInteger(inputStr, 10);
        // 将 BigInteger 对象转换为十六进制字符串
        String hexValue = decimalValue.toString(16);
        // 输出结果长度为 32 字节
        byte[] output = new byte[32];
        try {
            NativeLibrary.INSTANCE.alph_hash(output, hexValue);
            // 处理输出结果
        } catch (Exception e) {
            System.err.println("调用本地方法失败: " + e.getMessage());
            e.printStackTrace();
        }


        String s = bytesToHex(output);
        System.out.println("加密结果"+s);
        return s;
    }

    public static String bytesToHex(byte[] bytes) {
        StringBuilder hexString = new StringBuilder();
        for (byte b : bytes) {
            String hex = Integer.toHexString(0xff & b);
            if (hex.length() == 1) {
                hexString.append('0');
            }
            hexString.append(hex);
        }
        return hexString.toString();
    }


}
