|
|
@@ -8,7 +8,9 @@ import ( |
|
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" |
|
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" |
|
|
|
"crypto/sha256" |
|
|
|
"encoding/hex" |
|
|
|
"encoding/json" |
|
|
|
"fmt" |
|
|
|
"github.com/gin-gonic/gin" |
|
|
|
"github.com/tidwall/gjson" |
|
|
|
"strings" |
|
|
@@ -40,12 +42,12 @@ func CallbackChuanshanjia(c *gin.Context) { |
|
|
|
} |
|
|
|
} |
|
|
|
keyStr := spaceKey + ":" + transId |
|
|
|
h := sha256.New() |
|
|
|
//写入数据:将字符串 s 转换为字节切片并写入哈希对象 h。这一步是计算哈希的关键。 |
|
|
|
h.Write([]byte(keyStr)) |
|
|
|
//计算哈希值:h.Sum(nil) 计算当前哈希值并返回一个字节切片 bs。传入 nil 表示不需要额外的字节切片来存储结果。 |
|
|
|
bs := h.Sum(nil) |
|
|
|
if string(bs) != sign { |
|
|
|
// 1. 使用SHA256算法计算摘要 |
|
|
|
hash := sha256.Sum256([]byte(keyStr)) |
|
|
|
// 2. 将摘要转换为十六进制字符串 |
|
|
|
signStr := hex.EncodeToString(hash[:]) |
|
|
|
fmt.Println(signStr) |
|
|
|
if strings.Contains(signStr, sign) == false { |
|
|
|
c.String(200, "{\"is_verify\":true,\"reason\":50002}") |
|
|
|
return |
|
|
|
} |
|
|
|