提交common

This commit is contained in:
liuy 2024-08-01 17:22:26 +08:00
parent 1df32d2ff3
commit e51790064e
2 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1,36 @@
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认证授权加密类
*
* @Authorliuyang
* @Packagecom.hzya.frame.ttxofs
* @ProjectkangarooDataCenterV3
* @nameHexUtil
* @Date2024/7/29 14:22
* @FilenameHexUtil
*/
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;
}
}

View File

@ -1,3 +1,6 @@
import cn.hutool.core.util.HexUtil;
import com.hzya.frame.ttxofs.OfsHexUtil;
/**
* @Content
* @Author 👻👻👻👻👻👻👻👻👻👻 gjh
@ -5,4 +8,18 @@
* @Version 1.0
*/
public class Test {
public static void main(String[] args) {
OfsHexUtil h = new OfsHexUtil();
String data = "{\n" +
" \"created_start\": \"2024-03-27 12:03:30\",\n" +
" \"created_end\": \"2024-03-27 12:04:00\",\n" +
" \"clientCode\": \"LETS\",\n" +
" \"status\": 900,\n" +
" \"internalInstructionType\": \"SALES\",\n" +
" \"pageNo\": 1,\n" +
" \"pageSize\": 50\n" +
"}";
String json = h.sign("ofs.shipment.search", data, "json", "1023142858", "1.0", "382e4a2584027a36ac9431103", "123456789");
System.out.println(json);
}
}