hasGoodComplexity 检查密码复杂度
(password string)
| 361 | |
| 362 | // hasGoodComplexity 检查密码复杂度 |
| 363 | func hasGoodComplexity(password string) bool { |
| 364 | var hasUpper, hasLower, hasDigit, hasSpecial bool |
| 365 | |
| 366 | for _, char := range password { |
| 367 | switch { |
| 368 | case char >= 'A' && char <= 'Z': |
| 369 | hasUpper = true |
| 370 | case char >= 'a' && char <= 'z': |
| 371 | hasLower = true |
| 372 | case char >= '0' && char <= '9': |
| 373 | hasDigit = true |
| 374 | case !((char >= 'A' && char <= 'Z') || (char >= 'a' && char <= 'z') || (char >= '0' && char <= '9')): |
| 375 | hasSpecial = true |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | // 至少包含3种类型的字符 |
| 380 | count := 0 |
| 381 | if hasUpper { |
| 382 | count++ |
| 383 | } |
| 384 | if hasLower { |
| 385 | count++ |
| 386 | } |
| 387 | if hasDigit { |
| 388 | count++ |
| 389 | } |
| 390 | if hasSpecial { |
| 391 | count++ |
| 392 | } |
| 393 | |
| 394 | return count >= 3 |
| 395 | } |
| 396 | |
| 397 | // Encryption scenario types |
| 398 | const ( |
no outgoing calls
no test coverage detected