Mail Archives: djgpp/2002/03/17/04:01:08
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 -