delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/03/17/04:01:08

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
X-Trace-PostClient-IP: 24.67.16.79
From: Brian Inglis <Brian DOT Inglis AT SystematicSw DOT ab DOT ca>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: password and masking
Organization: Systematic Software
Message-ID: <82m89ugtcb1vtvu0n9cc9a73t157j58uif@4ax.com>
References: <a64q59$psf$1 AT iac5 DOT navix DOT net> <fc DOT 000f77f3001f30ab3b9aca00e8ae905a DOT 1f30d5 AT bni DOT mg>
X-Newsreader: Forte Agent 1.9/32.560
MIME-Version: 1.0
Lines: 47
Date: Sun, 17 Mar 2002 08:51:04 GMT
NNTP-Posting-Host: 24.71.223.147
X-Complaints-To: abuse AT shaw DOT ca
X-Trace: news2.calgary.shaw.ca 1016355064 24.71.223.147 (Sun, 17 Mar 2002 01:51:04 MST)
NNTP-Posting-Date: Sun, 17 Mar 2002 01:51:04 MST
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On Thu, 07 Mar 2002 08:20:03 +0300, "NirinaMichel
Ratoandromanana/DS-INFO" <n DOT ratoandromanana AT bni DOT mg> wrote:

>Erratum: the correct code should be this:
>
>unsigned char *getpwd (char prompt[], char *password)
>{
>	unsigned char *p = password;
>	int c;
>	printf ("%s", prompt);
>	while (1)
>	{
>		c = getch();	//get char without echo, see getch vs. getche
>		// terminate on end of line or file ^j, ^m, ^d, ^z
>		if (c == '\r' || c == '\n' || c == '\004' || c == '\032')
>			break;
>		else if (c == '\b')
>		{
>			p--;
>//to get back and erase the previous * and get back again
>			printf ("\0x1B \0x1B");
>			continue;
>		}
>		else
>		{
>			printf ("*");
>			*p++ = c;
>		}		
>	}
>	*p = '\0';
>	printf ("\n");
>	return p;
>}

echoing no characters, space characters, or a small random number
(1-3) of stars makes the length of the password less obvious if
someone is snooping nearby

-- 

Thanks. Take care, Brian Inglis 	Calgary, Alberta, Canada

Brian DOT Inglis AT CSi DOT com 	(Brian dot Inglis at SystematicSw dot ab dot ca)
    fake address		use address above to reply

tosspam AT aol DOT com abuse AT aol DOT com abuse AT yahoo DOT com abuse AT hotmail DOT com abuse AT msn DOT com abuse AT sprint DOT com abuse AT earthlink DOT com abuse AT cadvision DOT com abuse AT ibsystems DOT com uce AT ftc DOT gov
						spam traps

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019