Created
July 26, 2019 14:14
-
-
Save jackinf/b6d0413bde24ef6e03fe2497468708ac to your computer and use it in GitHub Desktop.
A bit rewritten version of https://gist.github.com/AntonGrig/dbeaa3fb610b0ee86dd50b863315f034
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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