Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.60 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     string password;
  10.     bool specialChars = 0, CapitalLetters = 0, smallLetters = 0, Numbers = 0;
  11.     cin>>password;
  12.  
  13.     if(password.length()>8)
  14.     {
  15.         for(int i = 0; i<password.length(); i++)
  16.     {
  17.         if(!((password[i]<='9' && password[i]>='0') || (password[i]<='Z' && password[i]>='A') || (password[i]<='z' && password[i]>='a')))
  18.         {
  19.  
  20.             specialChars = true;
  21.             continue;
  22.         }
  23.  
  24.          if(password[i]<='Z' && password[i]>='A')
  25.         {
  26.  
  27.             CapitalLetters = true;
  28.             continue;
  29.         }
  30.  
  31.         if(password[i]<='z' && password[i]>='a')
  32.         {
  33.  
  34.             smallLetters = true;
  35.             continue;
  36.         }
  37.         if(password[i]<='9' && password[i]>='0')
  38.         {
  39.  
  40.             Numbers = true;
  41.             continue;
  42.         }
  43.  
  44.  
  45.     }
  46.     if(Numbers + smallLetters + CapitalLetters + specialChars == 4)
  47.         {
  48.             cout<<"You have a pretty strong password"<<endl;
  49.         }
  50.      if(Numbers==0)
  51.      {
  52.          cout<<"Your password must contain a number"<<endl;
  53.      }
  54.       if(CapitalLetters==0)
  55.      {
  56.          cout<<"Your password must contain a capital letter"<<endl;
  57.      }
  58.      if(smallLetters==0)
  59.      {
  60.          cout<<"Your password must contain a small letter"<<endl;
  61.      }
  62.      if(specialChars==0)
  63.      {
  64.          cout<<"Your password must contain a special character"<<endl;
  65.      }
  66.  
  67.  
  68.     } else
  69.     {
  70.         cout<<"Your password is too short"<<endl;
  71.     }
  72.  
  73.  
  74.  
  75.     return 0;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement