You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
package com.dsideal.gw.Util;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.jfinal.kit.StrKit;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Page;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
|
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
public class CommonUtil {
|
|
|
|
|
//在独立的main函数中,使用下面的方式进行声明logback对象
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(CommonUtil.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 加签
|
|
|
|
|
*
|
|
|
|
|
* @param map
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public static String Sign(Map<String, Object> map, String signKey) {
|
|
|
|
|
if (map == null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
List<String> keyList = new ArrayList<>(map.keySet());
|
|
|
|
|
Collections.sort(keyList);
|
|
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
|
|
for (int i = 0; i < keyList.size(); i++) {
|
|
|
|
|
String key = keyList.get(i);
|
|
|
|
|
Object value = map.get(key);
|
|
|
|
|
sb.append(key + "=" + value + "&");
|
|
|
|
|
}
|
|
|
|
|
String signStr = sb.substring(0, sb.length() - 1) + signKey;
|
|
|
|
|
String md5Str = DigestUtils.md5Hex(signStr);
|
|
|
|
|
return md5Str;
|
|
|
|
|
}
|
|
|
|
|
}
|