MCPcopy Create free account
hub / github.com/astercloud/aster / maskValue

Method maskValue

pkg/security/redaction.go:102–123  ·  view source on GitHub ↗

maskValue 创建掩码值

(value string, maskLength int)

Source from the content-addressed store, hash-verified

100
101// maskValue 创建掩码值
102func (r *PIIRedactor) maskValue(value string, maskLength int) string {
103 if value == "" {
104 return value
105 }
106
107 if maskLength <= 0 {
108 return strings.Repeat("*", len(value))
109 }
110
111 if len(value) <= maskLength {
112 return strings.Repeat("*", len(value))
113 }
114
115 // 保留首尾字符,中间用*替换
116 end := len(value) - 1
117 if len(value) <= 2 {
118 return strings.Repeat("*", len(value))
119 }
120
121 masked := string(value[0]) + strings.Repeat("*", maskLength) + string(value[end])
122 return masked
123}
124
125// AddCustomPIIType 添加自定义PII类型
126func (r *PIIRedactor) AddCustomPIIType(piiType PIIType, replacement string) {

Callers 1

RedactWithMaskingMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected