chore: 并入 iotlcm-upstream-chan 历史到 upstream-chan/(原提交 1e74497)
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package yunda
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func BuildSign(appKey, appSecret string, params map[string]string) string {
|
||||
values := make(map[string]string, len(params)+2)
|
||||
for key, value := range params {
|
||||
values[key] = value
|
||||
}
|
||||
values["appKey"] = appKey
|
||||
values["appSecret"] = appSecret
|
||||
keys := make([]string, 0, len(values))
|
||||
for key := range values {
|
||||
keys = append(keys, key)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
source := appKey
|
||||
for _, key := range keys {
|
||||
source += key + values[key]
|
||||
}
|
||||
source += appKey
|
||||
sum := md5.Sum([]byte(source))
|
||||
return strings.ToUpper(hex.EncodeToString(sum[:]))
|
||||
}
|
||||
Reference in New Issue
Block a user