Well i am a starter in programming and need ur help. M using older version of borland c++ for programming. M trying to make a program which adds users login and password information and also verifies the correct login and password by accessing the contents of those files. but there is some problem in coding and m not able to get it so plzzz help me out. Also tell me a method if possible to encrypt the password and hide it from showing on user screen instead of password it shud show "*" eg password is asdf then while prompting for password it shud show ****.
Here is ma code. Need ur help.............
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<stdio.h>
#include<string.h>
int n=0;
class a
{
char u_name[20],u_pass[12],uname[20],upass[12];
public:
s()
{
int iNum1,iNum2,i,j;
iNum1=strcmp(uname,u_name);
iNum2=strcmp(upass,u_pass);
if(iNum1==iNum2==0)
{
n=1;
cout<<"\n\n\n\n\n\n\n\n\n\t\t\t ------ USER AUTHENTICATED ------";
return n;
}
else
{
n=2;
cout<<"\n\n\n\n\n\n\n\n\n\t\t\t ------ WRONG PASSWORD ------";
return n;
}
}
void getdata()
{
cout<<"\n\n\n\n\n\n\t\t\t\t USERNAME - ";
gets(u_name);
cout<<"\n\n\t\t PASSWORD (12 digit max.) - ";
gets(u_pass);
}
void getpass()
{
cout<<"\n\n\n\n\n\n\t\t\t\t USERNAME - ";
gets(uname);
cout<<"\n\n\t\t PASSWORD (12 digit max.) - ";
gets(upass);
}
void outdata()
{
cout<<"\n\n\n\n\n\t\t\t UserName:- ";puts(u_name);
cout<<"\n\n\t\t\t Password :- ";puts(u_pass);
}
};
void main()
{
a obj;
ifstream ifile;
ofstream ofile;
int c;
clrscr();
cout<<"1.Enter\n2.Check\n3.Display";
cin>>c;
switch(c)
{
case 1:
ofile.open("pass.dat",ios::app|ios::binary);
int n1;
cout<<"\nENTER THE LIST OF RECORDS TO INPUT : ";
cin>>n1;
clrscr();
for(int i=0;i<n1;i++)
{
clrscr();
obj.getdata();
ofile.write((char*) &obj,sizeof(obj));
}
ofile.close();
break;
case 2:
clrscr();
obj.getpass();
ifile.open("pass.dat",ios::in|ios::binary);
while(!ifile.eof())
{
ifile.read((char*) &obj,sizeof(a));
if(ifile.eof())
break;
obj.s();
}
ifile.close();
switch(n)
{
case 1:
cout<<"\n\n\t\t\t------ PRESS ENTER TO PROCEED ------";
getch();
break;
case 2:
cout<<"\n\n\t\t\t ------ WRONG PASSWORD ------";
cout<<"\n\t\t\t------ PRESS ENTER TO TRY AGAIN ------";
getch();
break;
} break;
case 3:
ifile.open("pass.dat",ios::in|ios::binary);
while(!ifile.eof())
{
ifile.read((char*) &obj,sizeof(a));
if(ifile.eof())
break;
clrscr();
obj.outdata();
getch();
}
ifile.close();
break;
}
}