微信 JS 接口签名校验工具
http://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=jsapisign
后台代码:
/**
* 分享的参数
* @author LHB
* @since JDK 1.8
*/
@ResponseBody
@RequestMapping(value = "/getShareParam")
public ResultOutDto getShareParam(HttpServletRequest request) throws Exception {
Ticket jsapi_ticket = new Ticket() ;
String url =URLDecoder.decode(request.getParameter("url"),"utf-8");
System.out.println(url);
String nonceStr = WeixinUtils.createNonceStr();
String timestamp = WeixinUtils.createTimestamp();
jsapi_ticket = CommonDataUtils.getTicket(Configure.APP_ID, Configure.APP_SECRET);
System.out.println(jsapi_ticket.getTicket());
//Sign签名
String signature= SignUtils.getSHA1Sign(jsapi_ticket.getTicket(), url, nonceStr, timestamp);
Map<String,Object> map = new HashedMap();
map.put("signature", signature);
map.put("nonceStr", nonceStr);
map.put("timestamp", timestamp);
return ResultOutDto.ok(map);
}