pii

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const Redacted = EncryptedValue("[REDACTED]")

Redacted is a constant for displaying redacted PII in logs/debug output.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter[ID fmt.Stringer] struct {
	// contains filtered or unexported fields
}

Adapter bridges generic envelope encryption to PII-specific interfaces. It hardcodes key version to 1 (PII keys don't rotate).

func NewAdapter

func NewAdapter[ID fmt.Stringer](
	encryptor *envelope.Encryptor,
	scope string,
) *Adapter[ID]

NewAdapter creates a new PII adapter for the given scope.

func (*Adapter[ID]) Decrypt

func (a *Adapter[ID]) Decrypt(ctx context.Context, subjectID ID, value EncryptedValue) (string, error)

Decrypt decrypts encrypted PII for the given subject. Key version is always 1 for PII (hardcoded).

func (*Adapter[ID]) Encrypt

func (a *Adapter[ID]) Encrypt(ctx context.Context, subjectID ID, plaintext string) (EncryptedValue, error)

Encrypt encrypts plaintext PII for the given subject.

type Decryptor

type Decryptor[ID fmt.Stringer] interface {
	Decrypt(ctx context.Context, subjectID ID, value EncryptedValue) (string, error)
}

Decryptor decrypts encrypted PII for a specific subject.

type EncryptedValue

type EncryptedValue string

EncryptedValue represents an encrypted piece of PII. It is an opaque base64-encoded string. Key version is always 1 (no rotation). When the encryption key is destroyed (crypto-shredding), this value becomes permanently unreadable.

func (EncryptedValue) IsEmpty

func (e EncryptedValue) IsEmpty() bool

IsEmpty returns true if the encrypted value is an empty string.

func (EncryptedValue) String

func (e EncryptedValue) String() string

String returns the underlying string value.

type Encryptor

type Encryptor[ID fmt.Stringer] interface {
	Encrypt(ctx context.Context, subjectID ID, plaintext string) (EncryptedValue, error)
}

Encryptor encrypts plaintext PII for a specific subject.

Jump to

Keyboard shortcuts

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