diff options
Diffstat (limited to 'internal/crypto/crypto.go')
-rw-r--r-- | internal/crypto/crypto.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/internal/crypto/crypto.go b/internal/crypto/crypto.go index 4c195508..0b0ab6c6 100644 --- a/internal/crypto/crypto.go +++ b/internal/crypto/crypto.go @@ -7,6 +7,7 @@ import ( "crypto/hmac" "crypto/rand" "crypto/sha256" + "crypto/subtle" "encoding/base64" "encoding/hex" "fmt" @@ -60,3 +61,7 @@ func GenerateUUID() string { b := GenerateRandomBytes(16) return fmt.Sprintf("%X-%X-%X-%X-%X", b[0:4], b[4:6], b[6:8], b[8:10], b[10:]) } + +func ConstantTimeCmp(a, b string) bool { + return subtle.ConstantTimeCompare([]byte(a), []byte(b)) == 1 +} |