From b4ec470e2fc430a83a7f03cca3d90be2b4f8ffd7 Mon Sep 17 00:00:00 2001 From: Alexander Lazarenko Date: Tue, 20 May 2025 21:53:09 +0300 Subject: [PATCH] Add password hashing function --- pkg/utils/crypto.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/utils/crypto.go b/pkg/utils/crypto.go index fd2995f..9030bf6 100644 --- a/pkg/utils/crypto.go +++ b/pkg/utils/crypto.go @@ -6,10 +6,18 @@ import ( "encoding/hex" ) -func GenerateVerifyKey(key string) string { +func generateHMAC(key string, data string) string { mac := hmac.New(md5.New, []byte(key)) - mac.Write([]byte(key)) + mac.Write([]byte(data)) return hex.EncodeToString(mac.Sum(nil)) } + +func GenerateVerifyKey(key string) string { + return generateHMAC(key, key) +} + +func GeneratePasswordHash(password string) string { + return generateHMAC("streaming", password) +}