mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
17 lines
334 B
Go
17 lines
334 B
Go
package utils
|
|
|
|
import (
|
|
"crypto/hmac"
|
|
"crypto/sha256"
|
|
"encoding/base64"
|
|
"encoding/hex"
|
|
)
|
|
|
|
func ComputeHmacSha256(message string, secret string) string {
|
|
key := []byte(secret)
|
|
h := hmac.New(sha256.New, key)
|
|
h.Write([]byte(message))
|
|
sha := hex.EncodeToString(h.Sum(nil))
|
|
return base64.StdEncoding.EncodeToString([]byte(sha))
|
|
}
|