Saturday, August 30, 2014

Password Security in C++

One of the basic protection that we can apply in our computer is the use of password. In this article I will show you a sample program that I wrote before a simple password security program in C++. What this program will do is to ask the user to enter the correct password as you run the program, every time the user type the password it display asterisk character to hide the real password underneath it protects the user from anyone who looks in their screen while they are typing for this password to access their system.

I hope you will find my work useful in your quest in learning C++ as your programming language.

Thank you very much.


Sample Screen Shoot of Our Program

Program Listing

#include <iostream>
#include <conio.h>

using namespace std;

void start();

void start()
{
    char ch;
     string password;
       system("cls");
       cout << "\n\n";
       cout << "\t\t ===== SIMPLE PASSWORD VALIDATION =====";
       cout << "\n\n";
       cout << "\t Created By: Mr. Jake Rodriguez Pomperada, MAED-IT";
      cout << "\n\n\n\n";
      cout << "Enter Your Password ==> ";

         while ((ch=getch()) != 13) {
              cout << "*";
               password+=ch;
         }

         if (password == "123") {
             cout << "\n\n\n";
             cout << "\t\t\t Password is Right Access is Granted !!!";
             cout << "\n\n\n";
             system("pause");
         }
       else {
             cout << "\n\n\n";
             cout << "\t\t\t Password is Invalid Access is Denied !!!";
             cout << "\n\n\n";
             system("pause");
             start();
    }
 }


int main() {
    start();
}



No comments:

Post a Comment