Password Masking

I wanted to mask a given string into '*' and use it in my project.please help....
Here is the program that I worked on till now...
[code]
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<fstream.h>
#include<ctype.h>
#include<dos.h>
#include<graphics.h>
void main()
{
char i,chr='y';
char pass[] = "password";
char Username[20];
char password[20];
int a=0,gr=0;
clrscr();
while(chr=='y')
{
cout<<" LOGIN DETAILS";
printf("\n\nUsername: ");
gets(Username);
printf("Password: ");

while( (i=getch())!= 13)
{password[a] = i;
printf("*");
a++;
}
password[a] = '\0';

if((strcmp(password,"christy\0")==0 && strcmp(Username,"Christy")==0)
|| (strcmp(password,"hilal\0")==0 && strcmp(Username,"Hilal")==0)
|| (strcmp(password,"jayan\0")==0 && strcmp(Username,"Jayan")==0))

{cout<<"\n\nACCESS GRANTED";
gr=1;
chr='n';
delay(350);
}
else
{cout<<"\nACCESS DENIED";
cout<<"\n\nDo you want to try again [y/n]: ";
cin>>chr;
clrscr();
}
}
[icode]
Those who are helping me please note that if you are editing the program, keep the complete program as an answer...as I am just a beginner student wont be knowing much....also note that please don't make it too complicated my teacher will scold me...[only 12 standard content]
Thank You in Advance
Christy
Last edited on
closed account (S6k9GNh0)
http://www.cplusplus.com/articles/E6vU7k9E/
The Article is very good. I went through it and I came across a few stuff which I don't know...although some of the content I knew but I don't know which to extract from the article and where to add it in mine./..plz help.....
I most sincerely appreciate for your kind help!!!
closed account (S6k9GNh0)
It's the last example using ncurses.
we haven't studied that thing....sorry
my program is correct....I just need to add
1.backspace
2.delete
and other keys
Last edited on
Somebody help me
I tried this way
but couldnt get this right...
have been stuck at this for months...
any help?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream.h>
#include <conio.h>
#include <string.h>
#include<stdio.h>
class password
	{
	char pass[20];		             		//Stores Actual Password
	char inpass[20];                        //Stores Input Password
   public:
	password();                      		//Initializes Actual Password
	void input();                           //Inputs the Password
	int comp();                             //Compares the Password
	};
void password::password()
	{
	clscr();
	cout<<"Enter original Password";
	gets(pass);
	}
void password::input()
	{
	char temp;
	cout<<"Enter Password(# to end): ";
	for(int i=0;temp!='#';i++)
		{
		temp=getch();
		inpass[i]=temp;
		cout<<"*";
		}
	pass[i]='\0';
	}
int  password::comp()
	{
	int temp;
	temp=strcmp(pass,inpass);
	return temp;
	}
int main()
	{
	password pass;
	clrscr();
	pass.input();
	if(pass.comp())
		cout<<"\nCorrect Password";
	else
		cout<<"\nIncorrect Password";
	getch();
	return 0;
	}
My program was fine...but only 'ENTER KEY' works.....I need codes for backspace delete key and other keys....In short it should be a perfect program....
Topic archived. No new replies allowed.