Commit 7d5ea99b authored by shajiaiming's avatar shajiaiming

md5 encrypt

parent 3e58950d
...@@ -2,9 +2,9 @@ package md5 ...@@ -2,9 +2,9 @@ package md5
import ( import (
config "bwallet/conf" config "bwallet/conf"
"bwallet/pkg/errno"
"bwallet/pkg/handler" "bwallet/pkg/handler"
"bwallet/pkg/util" "bwallet/pkg/util"
"errors"
"fmt" "fmt"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"net/url" "net/url"
...@@ -51,7 +51,7 @@ func verifySign(c *gin.Context) (map[string]string, error) { ...@@ -51,7 +51,7 @@ func verifySign(c *gin.Context) (map[string]string, error) {
if ok { if ok {
AppSecret = value["md5"] AppSecret = value["md5"]
} else { } else {
return nil, errno.ErrAk return nil, errors.New("ak Error")
} }
if debug == "1" { if debug == "1" {
...@@ -68,13 +68,13 @@ func verifySign(c *gin.Context) (map[string]string, error) { ...@@ -68,13 +68,13 @@ func verifySign(c *gin.Context) (map[string]string, error) {
timestamp := time.Now().Unix() timestamp := time.Now().Unix()
exp, _ := strconv.ParseInt(config.AppSignExpiry, 10, 64) exp, _ := strconv.ParseInt(config.AppSignExpiry, 10, 64)
tsInt, _ := strconv.ParseInt(ts, 10, 64) tsInt, _ := strconv.ParseInt(ts, 10, 64)
if tsInt > timestamp || timestamp-tsInt >= exp { if tsInt > timestamp || timestamp - tsInt >= exp {
return nil, errno.ErrTs return nil, errors.New("ts Error")
} }
// 验证签名 // 验证签名
if sn == "" || sn != createSign(req) { if sn == "" || sn != createSign(req) {
return nil, errno.ErrSn return nil, errors.New("sn Error")
} }
return nil, nil return nil, nil
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment