/** * <p>Desc:微信签名</p> * <p>参数名ASCII码从小到大排序(字典序)</p> * @param key weChat sign * @param params 参数 * @return sign * @throws Exception */ public static String weChatSign(String key,Map<String,Object> params) throws Exception{ SortedMap<String,Object> sort=new TreeMap<String,Object>(params); Set<String> keySet = sort.keySet(); StringBuilder sb = new StringBuilder(); for (Object k : keySet) { sb.append(k ).append("=").append(params.get(k)).append("&"); } sb.append("key=").append(key); String s = sb.toString(); return MD5Utils.encode(s).toUpperCase(); }
全文完,感谢您的耐心阅读~
欢迎大家关注我的公众号