aggreggate/uniques: use string builder for hashing

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I7371a878c05f704feef26c6e86a04b956a6a6964
This commit is contained in:
raf 2026-03-07 12:22:23 +03:00
commit d2f28ded61
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF

View file

@ -6,6 +6,7 @@ import (
"encoding/hex"
"fmt"
"os"
"strings"
"sync"
"time"
@ -71,8 +72,13 @@ func generateSalt(t time.Time, rotation string) string {
// Creates a privacy-preserving hash of visitor identity
func hashVisitor(ip, userAgent, salt string) string {
combined := ip + "|" + userAgent + "|" + salt
h := sha256.Sum256([]byte(combined))
var sb strings.Builder
sb.WriteString(ip)
sb.WriteString("|")
sb.WriteString(userAgent)
sb.WriteString("|")
sb.WriteString(salt)
h := sha256.Sum256([]byte(sb.String()))
return hex.EncodeToString(h[:])
}