Advertisement
xample

Password Checker Exercise

Sep 27th, 2019
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.56 KB | None | 0 0
  1. using System;
  2.  
  3. namespace PasswordChecker
  4. {
  5.   class Program
  6.   {
  7.     public static void Main(string[] args)
  8.     {
  9.       Console.WriteLine("Enter a password...");
  10.       string password = Convert.ToString(Console.ReadLine());
  11.       Console.WriteLine("Password inputted : " + password);
  12.       int score = 0;
  13.       int minLength = 8;
  14.       string uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  15.       string digits = "0123456789";
  16.       string specialChars = "#?!,-'/`_*$";
  17.       if (password.Length >= minLength){
  18.         score += 1;
  19.         Console.WriteLine("Password longer than (or = ) 8 characters! (+1 SCORE POINT)");
  20.       }else{
  21.         score -= 1;
  22.         Console.WriteLine("Password is shorter than 8 characters. (-1 SCORE POINT)");
  23.       }
  24.       if (Tools.Contains(password, uppercase)){
  25.         Console.WriteLine("Uppercase letter! (+1 SCORE POINT)");
  26.         score +=1;
  27.       }else{
  28.         Console.WriteLine("No uppercase letters! (-1 SCORE POINT)");
  29.         score -=1;
  30.       }
  31.       if (Tools.Contains(password, digits)){
  32.         Console.WriteLine("Digits included! (+1 SCORE POINT)");
  33.         score += 1;
  34.       }
  35.       else{
  36.         Console.WriteLine("Include digits! (-1 SCORE POINT)");
  37.         score -=1;
  38.       }
  39.       if (Tools.Contains(password, specialChars)){
  40.         Console.WriteLine("Special chars included! (+1 SCORE POINT)");
  41.         score += 1;
  42.       }
  43.       else{
  44.         Console.WriteLine("Include special chars! (-1 SCORE POINT)");
  45.         score -= 1;
  46.       }
  47.       Console.WriteLine("Final score : " + score);
  48.     }
  49.   }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement