safe "prompt for password" in console application

S

SharpCoderMP

hi,

i'm writing a console application and i would like to be able to safely
retrive password from the user, so noone can see how it is being typed.
consider this scenario:
Console.Write("Enter password:");
string pass = Console.ReadLine()

when this is called and user types, his passsword is displayed on the
screen. i would like to avoid that, and do not print any characters or
eventually print only '*' char for each user typed char. i thought i
could use Console.Read() in a loop, but i can't make it work the way i
want. it seems that Console.Read() works almost the same as
Console.ReadLine() - it waits until user types what he needs and hits
[enter] and then starts reading char by char.

i know i'm missing something...
 
S

SharpCoderMP

thanks! that's exacly what i need. i was browsing codeproject but didn't
came acros this. thanks for the link... boy it looks preety twisted :p
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top