支付成功通知
This commit is contained in:
36
utils/encryption_decryption/md5.go
Normal file
36
utils/encryption_decryption/md5.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package encryption_decryption
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func MakeSign(params map[string]interface{}) string {
|
||||
// 排序
|
||||
keys := make([]string, len(params))
|
||||
i := 0
|
||||
for k, _ := range params {
|
||||
keys[i] = k
|
||||
i++
|
||||
}
|
||||
sort.Strings(keys)
|
||||
byteBuf := bytes.NewBuffer([]byte{})
|
||||
encoder := json.NewEncoder(byteBuf)
|
||||
encoder.SetEscapeHTML(false)
|
||||
|
||||
err := encoder.Encode(params)
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
data := byteBuf.String()
|
||||
|
||||
h := md5.New()
|
||||
h.Write([]byte(strings.TrimRight(data, "\n")))
|
||||
return hex.EncodeToString(h.Sum(nil))
|
||||
}
|
||||
Reference in New Issue
Block a user