mirror of https://github.com/rocboss/paopao-ce
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
804 B
40 lines
804 B
2 years ago
|
// Copyright 2022 ROC. All rights reserved.
|
||
|
// Use of this source code is governed by a MIT style
|
||
|
// license that can be found in the LICENSE file.
|
||
|
|
||
|
package broker
|
||
3 years ago
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"sort"
|
||
|
|
||
2 years ago
|
"github.com/rocboss/paopao-ce/internal/conf"
|
||
3 years ago
|
"github.com/rocboss/paopao-ce/pkg/util"
|
||
2 years ago
|
"github.com/sirupsen/logrus"
|
||
3 years ago
|
)
|
||
|
|
||
2 years ago
|
func GetParamSign(param map[string]any, secretKey string) string {
|
||
3 years ago
|
signRaw := ""
|
||
|
|
||
|
rawStrs := []string{}
|
||
|
for k, v := range param {
|
||
|
if k != "sign" {
|
||
|
rawStrs = append(rawStrs, k+"="+fmt.Sprintf("%v", v))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
sort.Strings(rawStrs)
|
||
|
for _, v := range rawStrs {
|
||
|
signRaw += v
|
||
|
}
|
||
|
|
||
2 years ago
|
if conf.ServerSetting.RunMode == "debug" {
|
||
2 years ago
|
logrus.Info(map[string]string{
|
||
3 years ago
|
"signRaw": signRaw,
|
||
|
"sysSign": util.EncodeMD5(signRaw + secretKey),
|
||
|
})
|
||
|
}
|
||
|
|
||
|
return util.EncodeMD5(signRaw + secretKey)
|
||
|
}
|