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
}
本文介绍了一种使用Golang进行密码强度验证的方法,通过检查密码是否包含数字、大小写字母及特殊字符,确保密码安全性。但需注意,部分特殊字符如'#'和'|'不被允许。
1288

被折叠的 条评论
为什么被折叠?



