When creating a password, you may have seen verification requirements on the website, such as the password should be strong and contain the following requirements:
Let’s check these conditions one by one −
if (passwd.Length < 8 || passwd.Length > 14) return false;
if (!passwd.Any(char.IsLower)) return false;
if (passwd.Contains(" ")) return false;
if (!passwd.Any(char.IsUpper)) return false;
string specialCh = @"%!@#$%^&*()?/>.<,:;'\|}]{[_~`+=-" + "\""; char[] specialCh = specialCh.ToCharArray(); foreach (char ch in specialChArray) { if (passwd.Contains(ch)) return true; }
The above is the detailed content of C# program to check password validity. For more information, please follow other related articles on the PHP Chinese website!