Nisheeth

Password Checker

Sep 2nd, 2011
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.20 KB | None | 0 0
  1. //Includes Prototypes to some widows specific functions...
  2. #include "Functions.h"
  3.  
  4.  
  5. int main ()
  6. {
  7.     SetColor();         // Sets Text Colour to White
  8.     string Pass;
  9.     vector<char> Password;
  10.     cout << "Set Password:  ";
  11.     getline(cin,Pass);
  12.     for (int i = 0; i < Pass.size();i++)
  13.         Password.push_back(Pass[i]);
  14.     vector<char> Entry;
  15.    
  16.     Entry.reserve(10);
  17.     cout << "Password:  ";
  18.     int a;
  19.     for (int i =0;i>-1;i++)
  20.     {
  21.         a = i;
  22.         Entry.push_back(readkey());     //readkey()  returns ASCII code of the Key pressed...
  23.         cout << Entry[i];
  24.         if (Entry[i] == 13)
  25.             break;
  26.         ClearScreen();              //As the name suggests, Clears the screen
  27.         cout << "Password:  ";
  28.         Entry[i] = toupper(Entry[i]);
  29.         for (int j = 0; j < a+1;j++)
  30.         {
  31.             cout << "*";
  32.             if (Entry[i] == 8)
  33.             {
  34.                 a -= 1;
  35.                 cout << "\b";
  36.             }
  37.         }
  38.  
  39.         if (Entry[i] == 8)
  40.         {
  41.             i--;
  42.             Entry.pop_back();
  43.         }
  44.     }
  45.     Entry.pop_back();
  46.     bool X = false;
  47.     for (int i = 0; i <Entry.size() && i< Password.size();i++)
  48.     {      
  49.         if (Entry[i] == Password[i])
  50.         {
  51.             X = true;
  52.         }
  53.         else
  54.         {
  55.             X = false;
  56.             break;
  57.         }
  58.     }
  59.     if (X)
  60.         cout << "\nCorrect Password . . .";
  61.     else
  62.         cout << "\nIncorrect Password . . .";
  63.     PressAnyKey();
  64.     return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment