1
0
mirror of https://github.com/silenceper/wechat.git synced 2026-02-09 15:12:26 +08:00

Merge remote-tracking branch 'origin/release-2.0-hb' into release-2.0-hb

# Conflicts:
#	credential/work_js_ticket.go
#	work/js/js.go
#	work/message/reply.go
#	work/server/error.go
#	work/server/server.go
#	work/server/util.go
This commit is contained in:
wind
2024-11-15 11:44:40 +08:00
22 changed files with 673 additions and 31 deletions

View File

@@ -1,6 +1,7 @@
package util
import (
"bytes"
"crypto/sha1"
"fmt"
"io"
@@ -16,3 +17,16 @@ func Signature(params ...string) string {
}
return fmt.Sprintf("%x", h.Sum(nil))
}
func CalSignature(params ...string) string {
sort.Strings(params)
var buffer bytes.Buffer
for _, value := range params {
buffer.WriteString(value)
}
sha := sha1.New()
sha.Write(buffer.Bytes())
signature := fmt.Sprintf("%x", sha.Sum(nil))
return string(signature)
}