Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add a password to your program so others can't access it. (CONSOLE APPLICATIONS ONLY?)

Passworded Programs

Add a password to your program so others can't access it. (CONSOLE APPLICATIONS ONLY?)

by  TheProgramer  Posted    (Edited  )
Are you making an application that you don't want others, like your boss, to use? Well, Add a password to it!!!!!! I have created a simple code to allow you to add 1+ passwords to your program. Here is the code for a FORMATED DOCUMENT. Add it after the int main application, INSIDE the brackets:
Code:
int pass;
//The next 2 lines of code are the display of the password request/input of the password.
input:cout << "Please Enter Your Password: ";
cin >> pass; //Input of password
if (pass == 0) return 0; //When only 0 is typed, this will make the program exit.
if (pass == 1) goto ok;  //replace the current number with any other combination of numbers,
//to set the passwords for your users. you can have 1+ users. juast add aditional if
//statements like shown below. DO NOT DUPLICATE PASSWORDS.
if (pass == 2) goto ok;
if (pass == 3) goto ok;
if (pass == 4) goto ok;
if (pass == 5) goto ok;
if (pass == 6) goto ok;
goto input; // If password is incorrect, this will make the program ask for the password aagain.
OK://goto tag so that if password is correct it continues on with your program.
//Palce all of your program beyond this point.

      return 0;//This is the VERY END of the program. Do NOT add code past this point.

Here is the code for an UNFORMATTED DOCUMENT
Code:
#include <iostream.h>
#include <stdlib.h>

int main()
{
int pass;
//The next 2 lines of code are the display of the password request/input of the password.
input:cout << "Please Enter Your Password: ";
cin >> pass; //Input of password
if (pass == 0) return 0; //When only 0 is typed, this will make the program exit.
if (pass == 1) goto ok;  //replace the current number with any other combination of numbers,
//to set the passwords for your users. you can have 1+ users. juast add aditional if
//statements like shown below. DO NOT DUPLICATE PASSWORDS.
if (pass == 2) goto ok;
if (pass == 3) goto ok;
if (pass == 4) goto ok;
if (pass == 5) goto ok;
if (pass == 6) goto ok;
goto input; // If password is incorrect, this will make the program ask for the password aagain.
OK://goto tag so that if password is correct it continues on with your program.
//Palce all of your program beyond this point.

      return 0;//This is the VERY END of the program. Do NOT add code past this point.
}
I really hope this FAQ helpped.
Have Fun Programming!!!!!!!
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top