Saturday, June 12, 2021

Console Password in C++

 I simple console password in C++ language that I wrote which uses asterisk to hide the password. I hope you will like my work.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website, kindly contact me also at my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.





Program Listing

password.cpp

// password.cpp

// Jake Rodriguez Pomperada, MAED-IT, MIT

// www.jakerpomperada.com and www.jakerpomperada.blogspot.com

// jakerpomperada@gmail.com

// Bacolod City, Negros Occidental Philippines


#include <iostream>

#include <string>

#include <cstdio>

#include <conio.h>


int main()

{

  back:

     const std::string password("admin");

     std::string input;

     char c;


     std::cout << "\n==============================";

     std::cout << "\nConsole Password in C++";

     std::cout << "\n==============================";

     std::cout << "\n\n";


     std::cout << "Give Your Password: ";

     do

     {

         c = _getch();

         if( isprint(c) )

         {

             input += c;

             std::cout << '*';

         }

         else if( c == 8 && !input.empty())

         {

             input.pop_back();

             std::cout << "\b \b";

         }

     } while( c != 13 );

     std::cout <<"\n";

     if (input == password) {

         std::cout << "\nPassword is valid.\n";

         goto end;

        }

     else {

         std::cout << "\nInvalid password.\n";

        goto back;

     }

    end:

    std::cout <<"\n";

    std::cout <<"\tEnd of Program";

    std::cout <<"\n";

}




No comments:

Post a Comment