Explorar o código

新增微信接口校验

hsj hai 1 mes
pai
achega
bd3c34c56d

+ 2 - 2
src/main/java/top/husj/husj_wx/controller/WeChatController.java

@@ -30,9 +30,9 @@ public class WeChatController {
                 signature, timestamp, nonce, echostr);
 
         // 校验签名
-        String sha1 = SHA1.getSHA1(weChatProperties.getToken(), timestamp, nonce).trim();
+        String sha1 = SHA1.getSHA1(weChatProperties.getToken(), timestamp, nonce);
         log.info("本地生成微信服务器签名:{}", sha1);
-        if (sha1.equals(echostr.trim())) {
+        if (sha1.equals(signature)) {
             log.info("微信服务器验证成功");
             return echostr;
         } else {