#ifdef __linux__
#include <unistd.h>
#endif
#include <iostream>
#include <stdlib.h>
#ifndef __linux__
#include <conio.h>
#endif
using namespace std;
int main()
{
string pass = "";
#ifdef __linux__
system("clear");
pass = getpass("Enter Password : ");
#else
system("cls");
char ch;
cout << "Enter Password : ";
ch = _getch();
while(ch != 13) //character 13 is enter
{
pass.push_back(ch);
cout << '*';
ch = _getch();
}
#endif
if(pass == "Hello")
{
cout << "\nAccess granted :P\n";
//Further processing goes here...
}
else
{
cout << "\nAccess aborted...\n";
}
}
Master programming effortlessly with Simplest Codings. From core algorithms and LLMs to clean code in Java, C++, and Python—get clear, bite-sized tutorials and practical developer guides for all skill levels.
Tuesday, September 28, 2010
Simple password based authentication program in C
This is a simple password based authentication program which runs both on Windows as well as Linux.
Subscribe to:
Post Comments (Atom)
-
Overview of the SSL handshake Courtesy: http://www-01.ibm.com/support/knowledgecenter Steps involved in SSL handshake (Courtesy:...
-
To implement the kind of storage which stores strings as the search keys , there is a need to have special data structures which can store ...
-
A simple implementation of a packet sniffer in C on linux platform using the libpcap library. This packet sniffer currently sniffs IP , TCP ...
This looks more like C++ thing...... Why can't we use Char and Array (Pointer) to achieve String and also drop push_back .....
ReplyDeleteYeah you are right. Of course there are many ways to do it. I chose this one.
ReplyDelete