delorie.com/archives/browse.cgi | search |
X-Authentication-Warning: | delorie.com: mailnull set sender to djgpp-bounces using -f |
From: | "Philip Pemberton" <philpem AT bigfoot DOT com> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: password and masking |
Date: | Tue, 12 Mar 2002 22:12:32 -0000 |
Lines: | 47 |
Message-ID: | <a6luea$eck7m$1@ID-122086.news.dfncis.de> |
References: | <a64q59$psf$1 AT iac5 DOT navix DOT net> |
NNTP-Posting-Host: | host213-122-150-99.in-addr.btopenworld.com (213.122.150.99) |
X-Trace: | fu-berlin.de 1015971083 15094006 213.122.150.99 (16 [122086]) |
X-Priority: | 3 |
X-MSMail-Priority: | Normal |
X-Newsreader: | Microsoft Outlook Express 5.50.4133.2400 |
X-MimeOLE: | Produced By Microsoft MimeOLE V5.50.4133.2400 |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
"Amber N. Stange" <nicci AT eluviis DOT ohsu DOT edu> wrote in message news:a64q59$psf$1 AT iac5 DOT navix DOT net... > I am wanting to (for lack of a better word) mask a password for a login as > the user types the password. For instance much like Linux displays nothing > when a password is entered upon an attempted login. > > Well, in this specific case I am using fgets to get the password information > but of course that does me no good until enter has been pressed. What I was > wanting to mask the password with was, "*" (asterisks) much like many other > logins in other OSs and the old BBSs used to do. > > I have found thusfar that kbhit(); seems to be worthless for this. I have > thought about using a do { } while(); loop and testing with kbhit(); for > every keypress then once a keypress has been detected (ie, if(kbhit() !=0)) > set my pointer that points to fgets = to an enter copy the single char to a > string do a \b for a backspace and printf an asterisk and do it all over > again and again until the user hits enter or some other method of ending my > do while loop. > > I dont know if this works or would work and I am trying to implement it.. > But I am wondering if I am going about this the wrong way.. If so is there > another way to do this? If my method will work is there an easier way that > I am not thinking of minus setting up a ASM keyboard routine to get the > actual keypress codes or scan codes rather.. What about getch() (C) or cin (C++)? Just keep looping until getch/cin returns a carriage return (13 decimal). If it returns a delete (9 decimal IIRC) then back up one character [ printf("%c", 9); ], print a space then back up again. I used to do the same thing in Pascal. Later. -- Phil. philpem AT bigfoot DOT com http://www.philpem.btinternet.co.uk/
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |