37 lines
713 B
Go
37 lines
713 B
Go
|
// Package data_mask ...
|
||
|
//
|
||
|
// Description : data_mask ...
|
||
|
//
|
||
|
// Author : go_developer@163.com<白茶清欢>
|
||
|
//
|
||
|
// Date : 2023-05-24 14:40
|
||
|
package data_mask
|
||
|
|
||
|
import "strings"
|
||
|
|
||
|
// 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 {
|
||
|
return TypeMail
|
||
|
}
|