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
}

相关文章:

  • 2021-08-06
  • 2021-09-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-04
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-09
  • 2021-06-22
  • 2022-03-07
  • 2022-12-23
  • 2022-12-23
  • 2021-06-02
相关资源
相似解决方案