public bool alphabetDown(string size) { Symbols s = new Symbols(); for (int i = 0; i < size.Length; i++) { for (int j = 0; j < s.alphabetEuDown.Length; j++) { if (size[i] == s.alphabetEuDown[j]) { return(true); } } for (int j = 0; j < s.alphabetRuDown.Length; j++) { if (size[i] == s.alphabetRuDown[j]) { return(true); } } } return(false); }
public int CheckedPassword(string name) { bool check = false; int complexity = 0; if (Regex.IsMatch(name, @"[А-ЯЁ]") || (Regex.IsMatch(name, @"[A-Z]"))) { complexity += 5; } if (Regex.IsMatch(name, @"[a-z]") || (Regex.IsMatch(name, @"[а-яё]"))) { complexity += 5; } if (Regex.IsMatch(name, @"[0-9]")) { complexity += 5; } if (name.Length >= 8) { complexity += 10; } if (name.Length >= 10) { complexity += 15; } Symbols s = new Symbols(); for (int i = 0; i < name.Length - 1; i++) { if (Regex.IsMatch(name[i].ToString(), @"[А-ЯЁ]") && !Regex.IsMatch(name[i + 1].ToString(), @"[А-ЯЁ]")) { complexity += 5; } if (Regex.IsMatch(name[i].ToString(), @"[A-Z]") && !Regex.IsMatch(name[i + 1].ToString(), @"[A-Z]")) { complexity += 5; } if (Regex.IsMatch(name[i].ToString(), @"[a-z]") && !Regex.IsMatch(name[i + 1].ToString(), @"[a-z]")) { complexity += 5; } if (Regex.IsMatch(name[i].ToString(), @"[а-яё]") && !Regex.IsMatch(name[i + 1].ToString(), @"[а-яё]")) { complexity += 5; } if (Regex.IsMatch(name[i].ToString(), @"[0-9]") && !Regex.IsMatch(name[i + 1].ToString(), @"[0-9]")) { complexity += 5; } if (!check) { for (int j = 0; j < s.symbol.Length; j++) { if (name[i] == s.symbol[j]) { check = true; complexity += 10; } } } } return(complexity); }
public string randomIndex() { int index = rnd.Next() % 6; string nameChar = ""; Symbols s = new Symbols(); switch (index) { case 0: //число if (masFlag[0]) { nameChar += s.number[rnd.Next(s.number.Length)]; } else { return(randomIndex()); } break; case 1: //буквы строчыне русские if (masFlag[1] && masFlag[3]) { nameChar += s.alphabetRuDown[rnd.Next(s.alphabetRuDown.Length)]; } else { return(randomIndex()); } break; case 2: //буквы строчные английские if (masFlag[1] && masFlag[4]) { nameChar += s.alphabetEuDown[rnd.Next(s.alphabetEuDown.Length)]; } else { return(randomIndex()); } break; case 3: //буквы прописные русские if (masFlag[2] && masFlag[3]) { nameChar += s.alphabetRuUp[rnd.Next(s.alphabetRuUp.Length)]; } else { return(randomIndex()); } break; case 4: //буквы прописыне английские if (masFlag[2] && masFlag[4]) { nameChar += s.alphabetEuUp[rnd.Next(s.alphabetEuUp.Length)]; } else { return(randomIndex()); } break; case 5: //знак if (masFlag[5]) { nameChar += s.symbol[rnd.Next(s.symbol.Length)]; } else { return(randomIndex()); } break; } return(nameChar); }