By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,894 Members | 1,942 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,894 IT Pros & Developers. It's quick & easy.

Encrypted input from user

P: n/a
Hi,

I am developing a console application and i would like to get userinput
for

Database User & Password.

The Password should be input as **********

Please can some help me out on this?

Thanks & Regards
JP

Sep 22 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Heres a simple way of doing it:

static string ReadLineButStarInput()
{
byte star = ASCIIEncoding.ASCII.GetBytes("*")[0];
ConsoleKeyInfo key = Console.ReadKey();
string input = "";

while (key.Key != ConsoleKey.Enter)
{
input += key.KeyChar;

Console.CursorLeft -= 1;
Console.OpenStandardOutput().WriteByte(star);
key = Console.ReadKey();

}
return input;

}

HTH
Ciaran O'Donnell

"gopal" wrote:
Hi,

I am developing a console application and i would like to get userinput
for

Database User & Password.

The Password should be input as **********

Please can some help me out on this?

Thanks & Regards
JP

Sep 22 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.