/** * 功能:生成签名结果 * * @param sArray 要签名的数组 * @param key 安全校验码 * @return 签名结果字符串 */ public static String BuildMysign(Map sArray, String key) { if (sArray != null && sArray.size() > 0) { StringBuilder prestr = CreateLinkString(sArray); // 把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串 return Md5Encrypt.md5(prestr.append(key).toString()); // 把拼接后的字符串再与安全校验码直接连接起来,并且生成加密串 } return null; }
/** * 调用php 使用Post方法提交数据值url * * @param url * @param paramMap * @return */ public static String getJsonStrByPostFromPhp(String url, Map<String, String> paramMap) { System.out.println("***********************php post method 调用接口begin*********************"); System.out.println("php interface url :" + url); String json = null; try { if (paramMap == null) { paramMap = new HashMap<String, String>(); } paramMap.put("USER_NAME", RmsGlobal.PHP_INTERFACE_USERNAME); paramMap.put("PASSWORD", Md5Encrypt.md5(RmsGlobal.PHP_INTERFACE_PASSWORD)); logMap(paramMap); json = Jsoup.connect(url) .ignoreContentType(true) .timeout(RmsGlobal.JSOUP_TIME_OUT) .data(paramMap) .method(Method.POST) .execute() .body(); } catch (IOException e) { e.printStackTrace(); } System.out.println("php return json is :" + json); System.out.println("***********************php post method 调用接口end*********************"); return json; }
public static String sign(String content, String privateKey) { if (privateKey == null) return null; String signBefore = (new StringBuilder(String.valueOf(content))).append(privateKey).toString(); /* * try { FileWriter writer = new FileWriter((new * StringBuilder("/highsolog/alipay_notify_log" * )).append(System.currentTimeMillis()).append(".txt").toString()); * writer.write(signBefore); writer.close(); } catch (Exception e) { * e.printStackTrace(); } */ return Md5Encrypt.md5(signBefore); }