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 Rhinorhino 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
Joined
Feb 19, 2005
Messages
3
Location
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

www.perfnurt.se
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top