security

package
v1.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package security provides small privacy-preserving primitives shared across Herald: peppered digests for PII that must be used as a stable key/label (rate-limit keys, audit fingerprints) without landing raw email/phone values in Redis or logs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Digester

type Digester struct {
	// contains filtered or unexported fields
}

Digester computes stable, non-reversible digests of PII using an HMAC keyed by a server-side pepper. The same input always maps to the same digest (so it is usable as a rate-limit / dedup key) but the raw value cannot be recovered from Redis or exported metrics.

func NewDigester

func NewDigester(pepper []byte) *Digester

NewDigester creates a Digester and copies its pepper. A Digester must not be copied after first use. An empty pepper is allowed (it uses HMAC-SHA256 with an empty key) but callers SHOULD supply a non-empty pepper in production; config.Validate enforces this at startup.

func (*Digester) Digest

func (d *Digester) Digest(value string) string

Digest returns a hex-encoded, peppered digest of the given value. Empty input returns an empty string so callers can distinguish "no value" from a hash of the empty string.

func (*Digester) DigestParts

func (d *Digester) DigestParts(parts ...string) string

DigestParts returns a peppered digest over multiple parts with an unambiguous separator so ("a","bc") and ("ab","c") do not collide.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL