C++ Login system Code

Posts 1–5 of 5 · Page 1 of 1
C++ Login system Code
Hello All ,

This login system to get access to program .

That's my code

Code:
#include <iostream>
using namespace std;
int main()
{
    string name,password;
    cout << "enter your name : ";
    cin >> name;
    cout << "enter your password : ";
    cin >> password;
    if (password == "123456")
    {
    cout << "Hello , " << name << endl;
    }
    else
    {
        cout << "Wrong Password" <<endl;
        return 0;
    }
    cout << "here comes our program . . . . . . ";
    return 0;



}
simple but nice , what about it ?
Code:
#include <iostream>
using namespace std;
int main()
{

    string name,password; int x = 1;
    login :
    cout << "enter your name : ";
    cin >> name;
    cout << "enter your password : ";
    cin >> password;
    if (password == "123456")
    {
    cout << "Hello , " << name << endl;
    }
    else if (x == 5)
    {
        cout << "Wrong Username Or Password for 5 times .. Program is terminating .";
        return 0;
    }
    else
    {
        cout << "Wrong Username Or Password , Please Try again . " << x << " Out Of 5" <<endl;
        x++;
        goto login;
    }
    cout << "here comes our program . . . . . . ";
    return 0;
That's make the user enter a wrong info. for 5 times then terminate [ doesn't terminate at the first time ] .
you can simply reverse the 'password' and thats no real login system ..
Quote Originally Posted by ARGB View Post
you can simply reverse the 'password' and thats no real login system ..
it just makes a nice touch for the program and we are here to discuss , put your code if you know better .
this nice ... god job
Ignoring the ease with which somebody could reverse your program and get the password.. the user could simply restart the program once they hit 5/5 and keep trying. You will want to create a temp file to hold some kind of timeout data. (IE 5/5 for the next 15 minutes) Even then, they could just change the computer's time and keep going.

Using a password on a program that is entirely client sided just isn't effective at stopping anybody who wants to get into it, so don't store any sensitive data in the program.
Posts 1–5 of 5 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?