Files
calypso/backend/internal/auth/token.go
2025-12-24 19:53:45 +00:00

21 lines
493 B
Go

package auth
import (
"crypto/sha256"
"encoding/hex"
)
// HashToken creates a cryptographic hash of the token for storage
// Uses SHA-256 to hash the token before storing in the database
func HashToken(token string) string {
hash := sha256.Sum256([]byte(token))
return hex.EncodeToString(hash[:])
}
// VerifyTokenHash verifies if a token matches a stored hash
func VerifyTokenHash(token, storedHash string) bool {
computedHash := HashToken(token)
return computedHash == storedHash
}