datamasking

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package datamasking erases selected data and composes encryption providers.

Index

Constants

View Source
const DefaultMask = "*****"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Provider      Provider
	IgnoreMissing bool
	Warn          func(context.Context, string)
}

type EraseOptions

type EraseOptions struct {
	Fields []string
	Rules  []FieldRule
	Rule   Rule
}

type Error

type Error struct {
	Name    string
	Message string
	Cause   error
}

func (*Error) Error

func (e *Error) Error() string

func (*Error) ErrorName

func (e *Error) ErrorName() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type FieldRule

type FieldRule struct {
	Field string
	Rule  Rule
}

FieldRule order is significant when expressions overlap.

type Masker

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

func New

func New(config Config) *Masker

func (*Masker) Decrypt

func (m *Masker) Decrypt(ctx context.Context, data any, options TransformOptions) (any, error)

func (*Masker) Encrypt

func (m *Masker) Encrypt(ctx context.Context, data any, options TransformOptions) (any, error)

func (*Masker) Erase

func (m *Masker) Erase(ctx context.Context, data any, options EraseOptions) (any, error)

type Provider

type Provider interface {
	Encrypt(context.Context, string, map[string]string) (string, error)
	Decrypt(context.Context, string, map[string]string) (string, error)
}

Provider owns ciphertext format, cryptography and authenticated context. Implementations must support concurrent calls and honor cancellation.

type Rule

type Rule struct {
	CustomMask  *string
	DynamicMask *bool
	Replace     func(string) (string, error)
}

Rule uses pointers to retain explicit false and empty custom masks. Replace is an application-owned string replacement strategy, with precedence over CustomMask and DynamicMask. The optional commons/regex module provides Regexp.Replacer for ECMAScript string replacement without a core dependency.

type TransformOptions

type TransformOptions struct {
	Fields  []string
	Context map[string]string
}

type Undefined

type Undefined struct{}

Undefined preserves missing JavaScript values separately from null.

Directories

Path Synopsis
kms module

Jump to

Keyboard shortcuts

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