File size: 407 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
package slack
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"fmt"
"time"
)
// Signature generates a signature for a Slack request.
func Signature(signingSecret string, ts time.Time, data []byte) string {
h := hmac.New(sha256.New, []byte(signingSecret))
_, err := fmt.Fprintf(h, "v0:%d:%s", ts.Unix(), data)
if err != nil {
panic(err)
}
return "v0=" + hex.EncodeToString(h.Sum(nil))
}
|