博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
微信公众平台基础配置
阅读量:4166 次
发布时间:2019-05-26

本文共 1163 字,大约阅读时间需要 3 分钟。

@ResponseBody    @RequestMapping(value = "/f")    public void getUser(Model model, HttpServletRequest request,                          HttpServletResponse response) throws IOException {        PrintWriter print;        /*         * 规则描述:         *1. 将token、timestamp、nonce三个参数进行字典序排序         *2. 将三个参数字符串拼接成一个字符串进行sha1加密         *3. 开发者获得加密后的字符串可与signature对比,标识该请求来源于微信         */	    String signature = request.getParameter("signature");	    String timestamp = request.getParameter("timestamp");	    String nonce = request.getParameter("nonce");	    String echostr = request.getParameter("echostr");	    String token = "beokwithanything";        List
a = new ArrayList
(); a.add(token); a.add(timestamp); a.add(nonce); Collections.sort(a); String hashcode = DigestUtils.shaHex(a.get(0)+a.get(1)+a.get(2)); System.out.println(signature); System.out.println(hashcode); // 通过检验signature对请求进行校验: // 若校验成功则原样返回 echostr,表示接入成功,否则接入失败 if (hashcode.equals(signature)){ print = response.getWriter(); print.write(echostr); print.flush(); } }

 

转载地址:http://zkgxi.baihongyu.com/

你可能感兴趣的文章
给JAR签名
查看>>
怎样用Java生成ZIP文件
查看>>
windows远程共享不能连接的解决方法
查看>>
SQL Server自增字段的方法
查看>>
java 反编译问题
查看>>
return 与 exit()的区别
查看>>
fflush(stdin);的作用
查看>>
欢迎使用CSDN-markdown
查看>>
python3 文件合并
查看>>
python3 字典遍历操作
查看>>
python 统计词频
查看>>
使用python字典合并文本
查看>>
python字典update()方法
查看>>
python format()方法
查看>>
python自顶向下的设计方法进行体育竞技分析
查看>>
python自底向上的执行单元测试
查看>>
软件开发方法基础
查看>>
python面向过程程序设计
查看>>
python绘制铅球的运行轨迹
查看>>
python面向对象程序设计
查看>>