1
0
mirror of https://github.com/silenceper/wechat.git synced 2026-02-07 14:12:27 +08:00

完善企业微信API

This commit is contained in:
hb
2021-10-28 14:21:02 +08:00
parent d3f1a83d46
commit 7e24cb9e8d
10 changed files with 952 additions and 0 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)
}