add new decrypt encrypt function to member

This commit is contained in:
Adrian Zürcher
2025-11-20 15:17:44 +01:00
parent 11b9c61113
commit 3b804ff8d1
4 changed files with 185 additions and 147 deletions

View File

@@ -1,6 +1,9 @@
package utils
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"fmt"
"net/mail"
"time"
@@ -34,3 +37,9 @@ func GetCurrentTime(loc *time.Location) string {
func GetCurrentDay(loc *time.Location) string {
return fmt.Sprint(time.Now().In(loc).Weekday())
}
func HashField(field string, token []byte) string {
h := hmac.New(sha256.New, token)
h.Write([]byte(field))
return hex.EncodeToString(h.Sum(nil))
}