From 516d03c267ebd6a1bc69a9140588ea3fb9bbd864 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AD=90=E9=93=AD?= Date: Fri, 5 Jul 2024 09:43:48 +0800 Subject: [PATCH] =?UTF-8?q?plugin=20code=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/union_pay/internal/po/po.go | 2 -- plugins/union_pay/internal/util.go | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/plugins/union_pay/internal/po/po.go b/plugins/union_pay/internal/po/po.go index 306dcf0..bf4ad6d 100644 --- a/plugins/union_pay/internal/po/po.go +++ b/plugins/union_pay/internal/po/po.go @@ -69,8 +69,6 @@ func (req *Notify) GetReId() string { } func (req *Notify) ToJson() []byte { - //kvRows := utils.SortStruct(req.Body) - //b, _ := json.Marshal(kvRows) b, _ := json.Marshal(req.Body) return b } diff --git a/plugins/union_pay/internal/util.go b/plugins/union_pay/internal/util.go index 2104b75..fa63dd7 100644 --- a/plugins/union_pay/internal/util.go +++ b/plugins/union_pay/internal/util.go @@ -26,8 +26,8 @@ func headers(config *Config, req po.Req, bizMethod string) map[string][]string { milliseconds := now.Unix()*1000 + int64(now.Nanosecond())/1e6 h.Add("reqTs", fmt.Sprintf("%d", milliseconds)) - encodedHash := utils.Sha(vo.Version, config.Config.AppId, bizMethod, req.GetReId(), string(req.ToJson())) - signValue, err := utils.Sign(encodedHash, utils.FormatPEMPrivateKey(config.Extra.RsaPrk)) + rehash := utils.Sha(vo.Version, config.Config.AppId, bizMethod, req.GetReId(), string(req.ToJson())) + signValue, err := utils.Sign(rehash, utils.FormatPEMPrivateKey(config.Extra.RsaPrk)) if err != nil { return nil } @@ -45,8 +45,8 @@ func verify(config *Config, req *po.Notify, notifyBizMethod string) error { if req.Headers.BizMethod != notifyBizMethod { return fmt.Errorf("业务方法不匹配") } - encodedHash := utils.Sha(req.Headers.Version, config.Config.AppId, req.Headers.BizMethod, req.GetReId(), string(req.ToJson())) - lowerStr := strings.ToLower(encodedHash) + rehash := utils.Sha(req.Headers.Version, config.Config.AppId, req.Headers.BizMethod, req.GetReId(), string(req.ToJson())) + lowerStr := strings.ToLower(rehash) if utils.Verify(lowerStr, req.Headers.Sign, utils.FormatPEMPrivateKey(config.Extra.RsaNpk)) { return nil }