mask

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreditCard added in v0.6.0

func CreditCard(cardNumber string, opts ...func(*Config[CreditCardConfig])) (string, error)

func DefaultMasker

func DefaultMasker[T any](m Masker[T]) defaultMasker

DefaultMasker takes a masker and return the default masker associated with.

func Email

func Email(email string, opts ...func(*Config[EmailConfig])) (string, error)

func FullName added in v0.6.0

func FullName(name string, opts ...func(*Config[FullNameConfig])) (string, error)

FullName masks a full name in the format "J*** ***** ***** D**".

func IPv4Addr

func IPv4Addr(ip string, opts ...func(*Config[IPv4AddrConfig])) (string, error)

func Of

func Of(kind string) (m defaultMasker, found bool)

Of returns the specific default masker of the given kind.

func Register

func Register(kind string, m defaultMasker)

Register registers a default masker to handle a specific kind of sensitive data.

Types

type Config

type Config[T any] struct {
	Symbol rune
	Kind   T
}

Config is the generic mask config required by any registered mask.

The Type parameter represents the mask specific config.

func DefaultConfig

func DefaultConfig[T any](t T) Config[T]

DefaultConfig wraps the specific mask config and returns a generic one with defaults.

type CreditCardConfig added in v0.6.0

type CreditCardConfig struct {
	MaskBankIdentifier bool // default false
}

type EmailConfig

type EmailConfig struct {
	MaskDomain bool // default false
}

type FullNameConfig added in v0.6.0

type FullNameConfig struct {
}

type IPv4AddrConfig

type IPv4AddrConfig struct {
	OctetsToMask   int  // default 1
	OneOctetSymbol bool // default false
}

type Masker

type Masker[T any] func(val string, opts ...func(*Config[T])) (string, error)

Masker presents the function type that masks must satisfy.

Jump to

Keyboard shortcuts

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