SignatureUtils-签名工具类
作用
本工具类主要提供参数签名的相关方法,本类提供的方法均为静态方法,可以直接调用。
API列表
/**
* 创建请求签名的方法
*
* @param paramMap 待签名的参数
* @param url 请求的Rest接口
* @param secretKey 签名KEY
* @return 返回创建的签名
*/
public static String createSign(Map<String, Object> paramMap, String url, String secretKey) {
// to do sth.
}
/**
* 校验签名的方法
*
* @param jsonString 待校验的参数字符串
* @param url 请求的Rest接口
* @param secretKey 签名KEY
* @return 返回检查结果
*/
public static boolean checkSign(String jsonString, String url, String secretKey) {
// to do sth.
}
用法
静态工具类方法,直接使用即可。
演示
Map<String, Object> map = Collections.mapOf(
"id", "value4",
"name", Collections.mapOf(
"food", "value3-2",
"test", "value3-1",
"key", "value3-10",
"absolute", "value3-8",
"age", "value3-22",
"zoo", "value3-77"
),
"share", "value2",
"operation", "value20",
"further", "value12",
"failed", "value100",
"i18n", "value1"
);
String queryString = toSortedParamString(map);
System.out.println(queryString);