You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dingtalk/sign.go

17 lines
350 B

package dingtalk
import (
"crypto/hmac"
"crypto/sha256"
"encoding/base64"
"fmt"
)
func (c *Client) sign(t int64) string {
secStr := fmt.Sprintf("%d\n%s", t, c.config.Secret)
hmac256 := hmac.New(sha256.New, []byte(c.config.Secret))
hmac256.Write([]byte(secStr))
result := hmac256.Sum(nil)
return base64.StdEncoding.EncodeToString(result)
}