diff options
author | 2023-09-08 22:45:17 -0700 | |
---|---|---|
committer | 2023-09-09 13:11:42 -0700 | |
commit | 48f6885f4472efbe0e23f990ae8d4545f9a6a73d (patch) | |
tree | a05b35013e65f95013f90006b07870ddaeaf4065 /internal/crypto/crypto.go | |
parent | 32d33104a4934771ca99b1bcfe55bd0e4e88809b (diff) | |
download | v2-48f6885f4472efbe0e23f990ae8d4545f9a6a73d.tar.gz v2-48f6885f4472efbe0e23f990ae8d4545f9a6a73d.tar.zst v2-48f6885f4472efbe0e23f990ae8d4545f9a6a73d.zip |
Add generic webhook integration
Diffstat (limited to 'internal/crypto/crypto.go')
-rw-r--r-- | internal/crypto/crypto.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/internal/crypto/crypto.go b/internal/crypto/crypto.go index 44854910..fc974a1f 100644 --- a/internal/crypto/crypto.go +++ b/internal/crypto/crypto.go @@ -4,6 +4,7 @@ package crypto // import "miniflux.app/v2/internal/crypto" import ( + "crypto/hmac" "crypto/rand" "crypto/sha256" "encoding/base64" @@ -48,3 +49,9 @@ func HashPassword(password string) (string, error) { bytes, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost) return string(bytes), err } + +func GenerateSHA256Hmac(secret string, data []byte) string { + h := hmac.New(sha256.New, []byte(secret)) + h.Write(data) + return hex.EncodeToString(h.Sum(nil)) +} |