34 lines
726 B
Go
34 lines
726 B
Go
|
// Package data_mask ...
|
||
|
//
|
||
|
// Description : data_mask ...
|
||
|
//
|
||
|
// Author : go_developer@163.com<白茶清欢>
|
||
|
//
|
||
|
// Date : 2023-05-23 14:25
|
||
|
package data_mask
|
||
|
|
||
|
var (
|
||
|
maskInstanceTable = make(map[string]IDataMask)
|
||
|
defaultDataMask = &DefaultDataMask{}
|
||
|
)
|
||
|
|
||
|
func init() {
|
||
|
maskInstanceList := []IDataMask{}
|
||
|
for _, item := range maskInstanceList {
|
||
|
maskInstanceTable[item.Type()] = item
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Execute 执行数据脱敏
|
||
|
//
|
||
|
// Author : go_developer@163.com<白茶清欢>
|
||
|
//
|
||
|
// Date : 14:31 2023/5/23
|
||
|
func Execute(data string, maskType string) string {
|
||
|
dataMaskInstance, exist := maskInstanceTable[maskType]
|
||
|
if !exist || nil == dataMaskInstance {
|
||
|
dataMaskInstance = defaultDataMask
|
||
|
}
|
||
|
return dataMaskInstance.Mask(data)
|
||
|
}
|