urif
asked on
non echoed passwords
hi, part of the program that i am writing needs to get a password from the user.
i've been trying to come up with a way to not echo the password as the user types, much like the unix login or other command like programs like gpg, but sor far i only get exceptions.
is there a standard way to do this?
if possible i need a solution that migth work in both win32 and linux patforms.
thanks, any help is appreciated.
i've been trying to come up with a way to not echo the password as the user types, much like the unix login or other command like programs like gpg, but sor far i only get exceptions.
is there a standard way to do this?
if possible i need a solution that migth work in both win32 and linux patforms.
thanks, any help is appreciated.
ASKER
from the man page
DESCRIPTION
This function is obsolete. Do not use it.
DESCRIPTION
This function is obsolete. Do not use it.
I do not think we have a portable solution for this ...
For *nix, use getpass function
http://www.die.net/doc/linux/man/man3/getpass.3.html
Alternatively, you can use ncurses and turn screen echo off and on.
http://www.tldp.org/HOWTO/NCURSES-Programming-HOWTO/init.html#ECHONOECHO
https://www.experts-exchange.com/questions/10143125/password.html
https://www.experts-exchange.com/questions/20959038/Accepting-a-password-from-a-keypad-input.html
For *nix, use getpass function
http://www.die.net/doc/linux/man/man3/getpass.3.html
Alternatively, you can use ncurses and turn screen echo off and on.
http://www.tldp.org/HOWTO/NCURSES-Programming-HOWTO/init.html#ECHONOECHO
https://www.experts-exchange.com/questions/10143125/password.html
https://www.experts-exchange.com/questions/20959038/Accepting-a-password-from-a-keypad-input.html
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
i am not sure if readpassphrase() will be present on linux, but
you can check that out too. Plus i doubt if the method will
be portable to windows. to set the terminal echoing off, getpass()
issues ioctl() or tcsetattr().
hope this helps
you can check that out too. Plus i doubt if the method will
be portable to windows. to set the terminal echoing off, getpass()
issues ioctl() or tcsetattr().
hope this helps
ASKER
thanks.
everywhere i look is says don't use getpass()...
any idea why?
in anycase what about win32?
everywhere i look is says don't use getpass()...
any idea why?
in anycase what about win32?
Hmm, there are a few reasons for it
most of the implementations of getpass usually return the password
in a static buffer stored in the function. so subsequent calls to getpass()
will overwrite the previously read password. U may need to
copy the newly read password in your own buffer if u are going to use it
most of the implementations of getpass usually return the password
in a static buffer stored in the function. so subsequent calls to getpass()
will overwrite the previously read password. U may need to
copy the newly read password in your own buffer if u are going to use it
Hi urif,
there's a function getch() in "conio.h" (MSVC60) which returns a character without echoing it to the console. you'll have to print the '*' by youself then.
Cheers! S.
there's a function getch() in "conio.h" (MSVC60) which returns a character without echoing it to the console. you'll have to print the '*' by youself then.
Cheers! S.
ASKER
thanks everyone
getpass() call. take a look at its man page.