Skip to content

Instantly share code, notes, and snippets.

@jackinf
Created July 26, 2019 14:14
Show Gist options
  • Save jackinf/b6d0413bde24ef6e03fe2497468708ac to your computer and use it in GitHub Desktop.
Save jackinf/b6d0413bde24ef6e03fe2497468708ac to your computer and use it in GitHub Desktop.
using System;
using System.Linq;
namespace PasswordCheck
{
class Program
{
static void Main(string[] args)
{
while (true)
{
Console.WriteLine("Enter your password:");
var password = Console.ReadLine();
if (string.IsNullOrWhiteSpace(password))
{
Console.WriteLine("Password has not been entered. Try again.");
continue;
}
Console.WriteLine("Repeat your password:");
var repeatPassword = Console.ReadLine();
if (string.IsNullOrWhiteSpace(repeatPassword))
{
Console.WriteLine("Password has not been entered. Try again.");
continue;
}
if (password != repeatPassword)
{
Console.WriteLine("Password does not match. Try again.");
continue;
}
var score = 0;
if (password.Any(char.IsUpper))
{
score++;
}
if (password.Any(char.IsLower))
{
score++;
}
if (password.Any(char.IsDigit))
{
score++;
}
if (password.Any(char.IsSymbol))
{
score++;
}
Console.WriteLine("Your password is: " + password);
Console.WriteLine("Your password score is " + score);
break;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment