I'm gonna show you how to secure your console program with LOGIN. So you need to enter a username and password to access the content of program. This is basic and very easy script that everyone can learn, when i say "basic" i mean it isn't hackable, you can hack this if you know how. But enough of talk lets move on coding!
I will post here full code of program and explain(I will use Classes to store functions in).
- Code: Select all
#include <iostream>
#include <string> // You need this if you want to store more complex username and password.
using namespace std;
class Program
{
public:
void username_func()
{
system("CLS");
system("TITLE Basic protection of program");
cout << "ACCESS DENIED! Please indentify yourself." << endl;
cout << "Enter username: ";
std::string username; // Username variable
cin >> username;
if (username == "-Th3V01D-") // If you want to store complex username like this, you will need string declaration
{
password_func();
}
else
{
username_func();
}
}
protected:
void password_func()
{
system("CLS");
cout << "ACCESS DENIED! Please indentify yourself." << endl;
cout << "Enter username: *********" << endl;
cout << "Enter password: ";
std::string password; // Password variable
cin >> password;
if (password == "y0ucan'tst0pm3")
{
access_granted();
}
else
{
password_func();
}
}
private:
void access_granted()
{
system("CLS");
system("COLOR A");
cout << "Welcome agent, -Th3V01D-" << endl;
cout << "Begin search database: ";
cin.get();
}
};
int main()
{
Program run;
run.username_func();
return 0;
}
Pretty cool huh???
Enjoy!
-Th3V01D-




