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
339 B

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