From 131fea8347eeaa464e77ef9b7fd0365fb5a7f52b Mon Sep 17 00:00:00 2001 From: listen <494177603@qq.com> Date: Wed, 1 Dec 2021 11:58:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E6=A3=80=E6=B5=8B=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- security_check.go | 53 +++++++++++++++++++++++++++++++++++++++++++++++ weixin.proto | 2 ++ 2 files changed, 55 insertions(+) create mode 100644 security_check.go diff --git a/security_check.go b/security_check.go new file mode 100644 index 0000000..b2d3825 --- /dev/null +++ b/security_check.go @@ -0,0 +1,53 @@ +package weixinrpc + +import ( + "encoding/json" + "strconv" + "time" + "git.tetele.net/tgo/crypter" + "github.com/golang/protobuf/proto" +) + +func ImgSecCheck(appId, appSecret,imgUrl string, url ...string) (error) { + + conn, err := rpc_server_conn(url...) + if err != nil { + return err + } + defer conn.Close() + + data := map[string]interface{}{} + data["app_id"] = appId + data["app_secret"] = appSecret + data["img_url"] = imgUrl + + data_json, err := json.Marshal(data) + if err != nil { + return err + } + + encryData := crypter.DesEn(string(data_json), DES_KEY) + + now_int64 := time.Now().Unix() + + now := strconv.FormatInt(now_int64, 10) + + sign := Sign(encryData, now) + + req := &Request{ + proto.String(encryData), + proto.String(now), + proto.String(sign), + nil} + + res := &Response{} + + err = conn.GetMiniappQrcode(req, res) + + if err != nil { + return err + } + + return nil +} + diff --git a/weixin.proto b/weixin.proto index 26a3a3f..37f4f87 100644 --- a/weixin.proto +++ b/weixin.proto @@ -26,4 +26,6 @@ service WeixinRpcService { rpc getAppOpenid(Request) returns (Response); // 获取app的openid rpc getMpUserInfo(Request) returns (Response); //公众号获取用户信息 rpc getMiniappQrcode(Request) returns (Response); //获取小程序码 + rpc imgSecCheck(Request) returns (Response); //检测图片内容是否合法 + rpc msgSecCheck(Request) returns (Response); //检测文本内容是否合法 } \ No newline at end of file