golang密码校验
时间:2020-04-13 14:26:28
收藏:0
阅读:174
golang密码校验
func verifyPassword(s string) bool {
var hasNumber, hasUpperCase, hasLowercase, hasSpecial bool
for _, c := range s {
switch {
case unicode.IsNumber(c):
hasNumber = true
case unicode.IsUpper(c):
hasUpperCase = true
case unicode.IsLower(c):
hasLowercase = true
case c == ‘#‘ || c == ‘|‘:
return false
case unicode.IsPunct(c) || unicode.IsSymbol(c):
hasSpecial = true
}
}
return hasNumber && hasUpperCase && hasLowercase && hasSpecial
}
原文:https://www.cnblogs.com/tomtellyou/p/12691045.html
评论(0)