X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f X-Trace-PostClient-IP: 24.67.16.79 From: Brian Inglis Newsgroups: comp.os.msdos.djgpp Subject: Re: password and masking Organization: Systematic Software Message-ID: <82m89ugtcb1vtvu0n9cc9a73t157j58uif@4ax.com> References: X-Newsreader: Forte Agent 1.9/32.560 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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" 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