2021-02-19 02:42:24 +00:00
|
|
|
package util
|
|
|
|
|
2021-12-22 17:16:08 +00:00
|
|
|
import "strings"
|
|
|
|
|
2021-02-19 02:42:24 +00:00
|
|
|
func StringSliceContains(slice []string, needle string) bool {
|
|
|
|
for _, s := range slice {
|
|
|
|
if s == needle {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
2021-12-22 17:16:08 +00:00
|
|
|
|
|
|
|
func MaskKey(key string) string {
|
2022-01-16 15:45:33 +00:00
|
|
|
if len(key) == 0 {
|
|
|
|
return "{empty}"
|
|
|
|
}
|
|
|
|
|
|
|
|
h := len(key) / 3
|
|
|
|
if h > 5 {
|
|
|
|
h = 5
|
|
|
|
}
|
|
|
|
|
|
|
|
maskKey := key[0:h]
|
|
|
|
maskKey += strings.Repeat("*", len(key)-h*2)
|
|
|
|
maskKey += key[len(key)-h:]
|
2021-12-29 07:25:31 +00:00
|
|
|
return maskKey
|
2021-12-22 17:16:08 +00:00
|
|
|
}
|