Password System :-

#include<iostream>
#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<windows.h>
using namespace std;
void gotoxy (int x, int y)
{
COORD coord;
coord.X = x; coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
int main()
{
char pass1[20],pass2[20];
int length,i,go=1,dif,c=0,p=0;
//-----------------------------------------------------------------------------
while(go!=0)
{
int uc=0,lc=0,dc=0,sc=0;
cout<<"Enter Your Password:";
cout<<"\n(It must contain 1 Capital,\n1 Small Letter & Special Sybmool)";
gotoxy (20,c);
int i=0;
pass1[0]=getch();
cout<<"*";
while(pass1[i]!=13 && i<20)
{

i++;
get1:
pass1[i]=getch();
cout<<"*";
if(pass1[i]==8)
{
if(p>=0)
{
p--;
i--;
cout<<"\b \b"<<"\b \b";
pass1[i]='\O';
}
else
{
p++;
goto get1;
}
}
else
p++;
}
pass1[i]='\O';
//------------------------------------------------------------------
length=strlen(pass1);
for(i=0;i<length;i++)
{
if((pass1[i]>='a')&&(pass1[i]<='z'))
lc++;
else if((pass1[i]>='A')&&(pass1[i]<='Z'))
uc++;
else if((pass1[i]>='0')&&(pass1[i]<='9'))
dc++;
else
sc++;
}
if(lc>=1 && uc>=1 && dc>=1 && sc>=1)
{
go=0;
}
else
{
go=1;
system("cls");
cout<<"Password is not containg(a..,A..,!..,1..0):\n";
c=1;
Beep(1000,250);
}
}
system("cls");
p=0;
//----------------------------------------------------------------
while(dif!=0)
{
cout<<"\nConfirm Your Password:";
int j=0;
pass2[0]=getch();
cout<<"*";
while(pass2[j]!=13)
{
j++;
get2:
pass2[j]=getch();
cout<<"*";
if(pass2[j]==8)
{
if(p>0)
{
p--;
j--;
cout<<"\b \b"<<"\b \b";
pass2[j]='\O';
}
else
{
p++;
goto get2;
}
}
else
p++;
}
pass2[j]='\O';
//-----------------------------------------------------------
cout<<"\n";
dif=strcmp(pass2,pass1);
if(dif==0)
{
cout<<"\nCongrats..!! Your Password is matching:"<<endl;
}
else
{
system("cls");
cout<<"Oh No...!! Password is not matching:";
Beep(1000,250);
}
}
getch();
return 0;
}

Output ::-
pass1pass2

 

Leave a comment