VB icon

No Control C Password

Email
Submitted on: 1/2/2015 7:55:00 AM
By: theMayor (from psc cd)  
Level: Beginner
User Rating: By 4 Users
Compatibility: C++ (general)
Views: 832
 
     This is a password script. Every charachter the user input it displays a star. the password is kcTHEgreat. Catches Control c (Taught to me by a friend :)) so the only way out is to enter the correct password. If you like and think it's secure put it in your autoexec.bat
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: No Control C Password
// Description:This is a password script. Every charachter the user input it displays a star. the password is 
kcTHEgreat. Catches Control c (Taught to me by a friend :)) so the only way out is to enter the correct password. If you like and think it's secure put it in your autoexec.bat
// By: theMayor (from psc cd)
//**************************************

#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
#include <signal.h>
#include <string>
#include <dos.h>
void restart();
void loop(int signal)
{
 return;
}
int main()
{
 system ("cls");
 char key;
 char password[] ="kcTHEgreat";// your password goes here
 int counter=0;
 char kcpassword[counter];
 cout << "Password: ";
 cout << flush;
 for (;;)
 {
 if (signal(SIGINT, loop)) {};
 cout << flush;
 key=getch();
 if (key=='\r')
 {
 break;
 }
 else
 {
 cout << flush;
 kcpassword[counter]=key;
 counter++;
 cout << "*";
 }
 }
 int flag=1;
 for (int x=0;x<counter;x++)
 {
 if (kcpassword[x]!=password[x] || strlen(password)!=counter)
 {
 flag=0;
 break;
 }
 }
 system ("cls");
 if (counter==0)
 restart();
 if (flag==0)
 {
 gotoxy(35,10);textcolor(12);cprintf("!!DENIED!!");
 delay(1000);
 restart();
 }
 else
 {
 gotoxy(30,10);textcolor(12);cprintf("!!ACCESS GRANTED!!");
 for (int x=0;x<3000;x++);
 delay(1000);
 }
 return 0;
}
void restart()
{
 main();
}


Other 6 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.