From 81355d4a3f05c65341557f165420c7fde4389a93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B0=E4=BA=AE?= Date: Tue, 8 Oct 2019 18:43:55 +0800 Subject: [PATCH] =?UTF-8?q?Update=20=E4=BC=98=E5=8C=96=20MD5=20=E7=AD=BE?= =?UTF-8?q?=E5=90=8D=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/route/middleware/sign/md5/md5.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/route/middleware/sign/md5/md5.go b/app/route/middleware/sign/md5/md5.go index 18d9b0f2..acbf20c8 100644 --- a/app/route/middleware/sign/md5/md5.go +++ b/app/route/middleware/sign/md5/md5.go @@ -41,7 +41,7 @@ func createMD5Sign(params url.Values) string { var key []string var str = "" for k := range params { - if k != "sn" && k != "ts" && k != "debug" { + if k != "sn" && k != "debug" { key = append(key, k) } } @@ -83,8 +83,10 @@ func verifyMD5Sign(c *gin.Context) (map[string]string, error) { } if debug == "1" { + currentUnix := util.GetCurrentUnix() + req.Add("ts", strconv.FormatInt(currentUnix, 10)) res := map[string]string{ - "ts": strconv.FormatInt(util.GetCurrentUnix(), 10), + "ts": strconv.FormatInt(currentUnix, 10), "sn": createMD5Sign(req), } return res, nil @@ -94,7 +96,7 @@ func verifyMD5Sign(c *gin.Context) (map[string]string, error) { // 验证过期时间 timestamp := time.Now().Unix() - if ts > timestamp || timestamp - ts >= exp { + if ts > timestamp || timestamp-ts >= exp { return nil, errors.New("ts Error") }