[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 305
  • Last Modified:

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.
0
urif
Asked:
urif
  • 3
  • 3
  • 2
  • +1
1 Solution
 
van_dyCommented:
on linux you have
getpass() call. take a look at its man page.
0
 
urifAuthor Commented:
from the man page

DESCRIPTION
       This function is obsolete. Do not use it.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
van_dyCommented:
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
0
 
urifAuthor Commented:
thanks.

everywhere i look is says don't use getpass()...
any idea why?

in anycase what about win32?
0
 
van_dyCommented:
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
0
 
skypalaeCommented:
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.
0
 
urifAuthor Commented:
thanks everyone
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now