mirror of
https://github.com/silenceper/wechat.git
synced 2026-11-16 05:12:03 +08:00
* feat: add aispeech dialog APIs * test: fix aispeech lint failures * test: satisfy aispeech interfacer lint
21 lines
454 B
Go
21 lines
454 B
Go
package encryptor
|
|
|
|
import (
|
|
"crypto/md5"
|
|
"encoding/hex"
|
|
"strconv"
|
|
)
|
|
|
|
// Sign calculates the aispeech request signature.
|
|
func Sign(token string, timestamp int64, nonce string, body []byte) string {
|
|
bodyMD5 := md5.Sum(body)
|
|
bodySign := hex.EncodeToString(bodyMD5[:])
|
|
|
|
h := md5.New()
|
|
h.Write([]byte(token))
|
|
h.Write([]byte(strconv.FormatInt(timestamp, 10)))
|
|
h.Write([]byte(nonce))
|
|
h.Write([]byte(bodySign))
|
|
return hex.EncodeToString(h.Sum(nil))
|
|
}
|