Files
commerce/events/hash.go
zeekay 1943f1c093 Hanzo Commerce
Multi-tenant commerce and billing: orders, subscriptions, invoices, plans,
usage metering and a credit ledger. One Go binary. MIT OR Apache-2.0.

Claude-Session: https://claude.ai/code/session_01SAtaDFm8VDiWrhYHNNtxMw
2026-09-23 21:52:16 -07:00

20 lines
442 B
Go

package events
import (
"crypto/sha256"
"encoding/hex"
"strings"
)
// SHA256Hex returns the lowercase hex SHA256 hash of a trimmed, lowercased string.
// Facebook CAPI requires user_data fields (em, ph) to be SHA256-hashed.
// Returns empty string for empty input.
func SHA256Hex(s string) string {
s = strings.ToLower(strings.TrimSpace(s))
if s == "" {
return ""
}
h := sha256.Sum256([]byte(s))
return hex.EncodeToString(h[:])
}