public serviceresponse IsPasswordStrong(string password) { serviceresponse rs = new serviceresponse(); if (string.IsNullOrWhiteSpace(password)) { rs.result = "Password cannot be empty"; rs.check = false; } if (password.Contains(" ")) { rs.result = "Password contains white spaces and its not acceptable"; rs.check = false; } else { var hasNumber = new Regex(@"[0-9]+"); var hasUpperChar = new Regex(@"[A-Z]+"); var hasLowerChar = new Regex(@"[a-z]+"); var hasMinimum8Chars = new Regex(@".{8,}"); var hasSymbols = new Regex(@"[!@#$%^&*()_+=\[{\]};:<>|./?,-]"); rs.check = hasNumber.IsMatch(password) && hasUpperChar.IsMatch(password) && hasLowerChar.IsMatch(password) && hasMinimum8Chars.IsMatch(password) && hasSymbols.IsMatch(password); rs.result = rs.check ? "Password is strong" : "Password is not strong"; } return(rs); }
protected bool Equals(serviceresponse other) { return(string.Equals(result, other.result)); }