aboutsummaryrefslogtreecommitdiff
path: root/internal/crypto/crypto.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/crypto/crypto.go')
-rw-r--r--internal/crypto/crypto.go7
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))
+}