Files
Kazier/backend/internal/service/checksum.go
T
2026-07-12 13:44:15 +02:00

20 lines
304 B
Go

package service
import (
"crypto/sha256"
"crypto/subtle"
)
func CreateSHA256Hash(data []byte) []byte {
hasher := sha256.New()
hasher.Write(data)
return hasher.Sum(nil)
}
func CompareHash(x, y []byte) bool {
if len(x) != len(y) {
return false
}
return subtle.ConstantTimeCompare(x, y) == 1
}