Advertisement
ASP_Volume3 Security #57559

Hidden Password

This code allows the user to imput a password (within a C++ program) without any text being displayed on-screen (not even *'s)

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
#include <iostream.h>
#include <conio.h>
bool passcheck(void) //checks password WITHOUT displaying the characters on-screen
{
	char password[7] = "outlaw"; //[] can be used instead, but it takes more memory, its quicker than counting though
	int plen = 6; //plen must be the number of letters in password
	char let;
	for(int i = 0; i < plen; i++)
	{
		let = getch();
		if(password[i] != let)
			return false;
	}
	return true;
}
//the above code immediately returns false if an incorrect password is imput
//if you want it to only return false at the end of the password, create a seperate bool variable
//to be returned at the end of the program
//instead of a for statement you can use (while x != 13) and hit enter at the end of the password
//(13 is the ascii value of enter)
Original Comments (3)
Recovered from Wayback Machine