Documentation
¶
Index ¶
- func ValidateEmail(email string) bool
- func ValidateIDCard(id string) bool
- func ValidatePhone(phone string) bool
- type AuditEntry
- type Config
- type Match
- type Pattern
- type Redactor
- func (r *Redactor) AddPattern(name, regex, replacement string)
- func (r *Redactor) ClearAuditLog()
- func (r *Redactor) CountPII(text string) map[string]int
- func (r *Redactor) Detect(text string) []Match
- func (r *Redactor) Disable()
- func (r *Redactor) Enable()
- func (r *Redactor) GetAuditLog() []AuditEntry
- func (r *Redactor) GetPatterns() []string
- func (r *Redactor) IsEnabled() bool
- func (r *Redactor) Redact(text string) string
- func (r *Redactor) RedactStruct(v interface{}) interface{}
- func (r *Redactor) RedactWithContext(text string) (string, []string)
- func (r *Redactor) Restore(text string, mapping map[string]string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateIDCard ¶
ValidateIDCard validates Chinese ID card number
func ValidatePhone ¶
ValidatePhone validates Chinese mobile phone number
Types ¶
type AuditEntry ¶
type AuditEntry struct {
Original string `json:"original"`
Detected []string `json:"detected"` // Types of PII found
Redacted string `json:"redacted"`
Timestamp string `json:"timestamp"`
}
AuditEntry represents a redaction audit log entry
type Config ¶
type Config struct {
Enabled bool `json:"enabled"`
RedactPhone bool `json:"redact_phone"`
RedactEmail bool `json:"redact_email"`
RedactIDCard bool `json:"redact_id_card"`
RedactBankCard bool `json:"redact_bank_card"`
RedactIP bool `json:"redact_ip"`
RedactAddress bool `json:"redact_address"`
CustomPatterns map[string]string `json:"custom_patterns"` // Name -> Regex
}
Config holds privacy configuration
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns default privacy configuration
type Redactor ¶
type Redactor struct {
// contains filtered or unexported fields
}
Redactor handles PII detection and redaction
func DefaultRedactor ¶
func DefaultRedactor() *Redactor
DefaultRedactor creates a redactor with default patterns
func NewRedactor ¶
NewRedactor creates a new redactor with the given configuration
func (*Redactor) AddPattern ¶
AddPattern adds a custom PII pattern
func (*Redactor) ClearAuditLog ¶
func (r *Redactor) ClearAuditLog()
ClearAuditLog clears the audit log
func (*Redactor) GetAuditLog ¶
func (r *Redactor) GetAuditLog() []AuditEntry
GetAuditLog returns the audit log
func (*Redactor) GetPatterns ¶
GetPatterns returns all configured patterns
func (*Redactor) RedactStruct ¶
func (r *Redactor) RedactStruct(v interface{}) interface{}
RedactStruct recursively redacts all string fields in a struct
func (*Redactor) RedactWithContext ¶
RedactWithContext redacts PII and returns detected types