2023-05-24 14:51:45 +08:00
|
|
|
// Package data_mask ...
|
|
|
|
//
|
|
|
|
// Description : data_mask ...
|
|
|
|
//
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
//
|
|
|
|
// Date : 2023-05-24 14:40
|
2023-10-19 17:25:09 +08:00
|
|
|
package strategy
|
2023-05-24 14:51:45 +08:00
|
|
|
|
2023-10-19 17:25:09 +08:00
|
|
|
import (
|
|
|
|
"git.zhangdeman.cn/zhangdeman/data_mask/define"
|
|
|
|
"strings"
|
|
|
|
)
|
2023-05-24 14:51:45 +08:00
|
|
|
|
|
|
|
// MailDataMask ...
|
|
|
|
//
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
//
|
|
|
|
// Date : 14:40 2023/5/24
|
|
|
|
type MailDataMask struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m MailDataMask) Mask(input string) string {
|
|
|
|
input = strings.TrimSpace(input)
|
|
|
|
if !strings.Contains(input, "@") || strings.HasPrefix(input, "@") {
|
|
|
|
// 不是邮箱
|
|
|
|
return input
|
|
|
|
}
|
|
|
|
arr := strings.Split(input, "@")
|
|
|
|
if len(arr) != 2 {
|
|
|
|
return input
|
|
|
|
}
|
|
|
|
|
|
|
|
return string(arr[0][0]) + "********" + string(arr[0][len(arr[0])-1]) + "@" + arr[1]
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m MailDataMask) Type() string {
|
2023-10-19 17:25:09 +08:00
|
|
|
return define.TypeMail
|
2023-05-24 14:51:45 +08:00
|
|
|
}
|