避免腾讯云使用以/开头的密码

This commit is contained in:
屈轩
2019-03-15 14:23:19 +08:00
parent ffb25c7121
commit c40dc1edcd
+9 -2
View File
@@ -36,8 +36,15 @@ func RandomPassword2(width int) string {
ps := PasswordStrength{}
var buf bytes.Buffer
for i := 0; i < width; i += 1 {
index := rand.Intn(len(CHARS))
ch := CHARS[index]
var ch byte
for {
index := rand.Intn(len(CHARS))
ch = CHARS[index]
if i == 0 && ch == '/' {
continue
}
break
}
if strings.IndexByte(DIGITS, ch) >= 0 {
ps.Digits += 1
} else if strings.IndexByte(LETTERS, ch) >= 0 {