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!

Hidding Text...

Status
Not open for further replies.

ZoomerX13

Programmer
Feb 19, 2005
3
0
0
US
HELP!!!! I have a program that runs in a Dos Prompt and has a password. I need to know how to hide the password so others can't see it when I enter it, and also so I can log out and leave the computer and not have people go after the password and get back in. Please help. THANKS!!
 
So do you really mean DOS, or a win32 console window?
Also, which compiler are you using?

--
 
Yoou need to catch each key press, and then store it and send a Dummy character to the screen
 
How? I am using DEVc++ 4.9.9.1 builtin window and it is in a dos prompt.
 
Code:
#include <conio.h>
#include <string>
#include <iostream>

std::string getPwd()
{
	std::cout << "Enter password:"; std::cout.flush();

	std::string pwd;
	int i=0;
	do
	{
		i = _getch();
		if (isalnum(i)) // a-z A-Z 0-9
		{
			std::cout << "*"; std::cout.flush();
			pwd+=i;
		}
	} while (i!=13); // Return

	return pwd;
}

/Per
[sub]
www.perfnurt.se[/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top