pii

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultScanners = []Scanner{
	{
		Name:    "Credit Card",
		Pattern: regexp.MustCompile(`\b(?:4[0-9]{3}[- ]?[0-9]{4}[- ]?[0-9]{4}[- ]?[0-9]{4}|(?:4[0-9]{12}(?:[0-9]{3})?)|5[1-5][0-9]{2}[- ]?[0-9]{4}[- ]?[0-9]{4}[- ]?[0-9]{4}|6(?:011|5[0-9][0-9])[- ]?[0-9]{4}[- ]?[0-9]{4}[- ]?[0-9]{4}|3[47][0-9]{2}[- ]?[0-9]{4}[- ]?[0-9]{4}[- ]?[0-9]{4}|3(?:0[0-5]|[68][0-9])[0-9][- ]?[0-9]{4}[- ]?[0-9]{4}[- ]?[0-9]{4}|(?:2131|1800|35\d{3})\d{11})\b`),
		Mask:    "****-****-****-****",
	},
	{
		Name:    "SSN",
		Pattern: regexp.MustCompile(`\b\d{3}-\d{2}-\d{4}\b`),
		Mask:    "***-**-****",
	},
	{
		Name:    "IPv4",
		Pattern: regexp.MustCompile(`\b(?:\d{1,3}\.){3}\d{1,3}\b`),
		Mask:    "*.*.*.*",
	},
	{
		Name:    "IPv6",
		Pattern: regexp.MustCompile(`\b(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}\b`),
		Mask:    "****:****:****:****:****:****:****:****",
	},
	{
		Name:    "Email",
		Pattern: regexp.MustCompile(`\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b`),
		Mask:    "****@****.***",
	},
	{
		Name:    "Phone",
		Pattern: regexp.MustCompile(`\b(?:\+?1[-. ]?)?\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})\b`),
		Mask:    "(***) ***-****",
	},
	{
		Name:    "IBAN",
		Pattern: regexp.MustCompile(`\b[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}\b`),
		Mask:    "**** **** **** ****",
	},
	{
		Name:    "Passport",
		Pattern: regexp.MustCompile(`\b[A-Z0-9]{6,9}\b`),
		Mask:    "*********",
	},
}

Functions

func MaskEmail

func MaskEmail(s string) string

func MaskPartial

func MaskPartial(s string) string

Types

type Engine

type Engine struct {
	Scanners []Scanner
}

func NewEngine

func NewEngine(scanners ...Scanner) *Engine

func (*Engine) Discover

func (e *Engine) Discover(input string) []string

func (*Engine) Mask

func (e *Engine) Mask(input string) string

type Scanner

type Scanner struct {
	Name    string
	Pattern *regexp.Regexp
	Mask    string
}

Jump to

Keyboard shortcuts

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