start working on the frontend side
This commit is contained in:
20
backend/internal/auth/token.go
Normal file
20
backend/internal/auth/token.go
Normal file
@@ -0,0 +1,20 @@
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user