如何使控制台隐藏键入的密码 [英] How to make the console hide passwords that are typed in
问题描述
我需要创建一个我编写支持的命令行应用程序
一个允许用户使用/ p的选项: *切换到指定
他们想要输入密码但隐藏它以便每个键
stroke生成''*''作为输出,隐藏什么是由
用户输入的。如果有人知道如何在C#中做到这一点,那么你的帮助将会很大。
赞赏。
感谢先进,
Ryan
Hi,
I need to make a command line application that I have written support
an option that allows the user to use the /p:* switch to specify that
they would like to type a password but have it hidden so that each key
stroke generates ''*'' as its output, hiding the what was typed by the
user. If anyone knows how to do this in C# your help would be greatly
appreciated.
Thanks in advanced,
Ryan
推荐答案
Ryan,
假设您使用的是TextBox密码输入,只需将
''PasswordChar''属性设置为非零值...
问候,
John Bendiksen
Ryan,
Assuming you are using a TextBox for the password entry, just set the
''PasswordChar'' property to a non-zero value...
Regards,
John Bendiksen
2006年2月6日15:02:44 -0800,JohnAtAphelion
< jb * *******@aphelion.net>写道:
On 6 Feb 2006 15:02:44 -0800, "JohnAtAphelion"
<jb********@aphelion.net> wrote:
Ryan,
假设您使用TextBox进行密码输入,只需将
''PasswordChar''属性设置为非零值...
问候,
John Bendiksen
Ryan,
Assuming you are using a TextBox for the password entry, just set the
''PasswordChar'' property to a non-zero value...
Regards,
John Bendiksen
控制台中没有GUI。
Ken Wilson
在卑诗省维多利亚寻求可行的工作
There''s no GUI in a console.
Ken Wilson
Seeking viable employment in Victoria, BC
2006年2月6日13:42 :22-0800, ry*********@netiq.com 写道:
On 6 Feb 2006 13:42:22 -0800, ry*********@netiq.com wrote:
我需要创建一个我写过支持的命令行应用程序
一个允许用户使用/ p的选项:*切换到指定
他们想要输入密码但隐藏它以便每个键
笔画生成''*''作为其输出,隐藏
用户键入的内容。如果有人知道如何在C#中做到这一点,那么你的帮助将会非常受欢迎。
先谢谢了,
瑞安
Hi,
I need to make a command line application that I have written support
an option that allows the user to use the /p:* switch to specify that
they would like to type a password but have it hidden so that each key
stroke generates ''*'' as its output, hiding the what was typed by the
user. If anyone knows how to do this in C# your help would be greatly
appreciated.
Thanks in advanced,
Ryan
原谅我,现在已经很晚了,所以我不打算输入任何示例代码但是
我会让你开始我将尝试的东西解。其他
我的方法不同,所以不要惊讶地看到正确的
在这里与我的答案,呵呵......
一次读取一个字符的字符输入并将其放入char
数组(计算上便宜)或将其附加到字符串
(计算成本高) 。当每个字符在输出中读出时,'*''为
控制台。
Ken Wilson
寻求可行的就业机会在维多利亚州,BC
Forgive me, it''s late here so I won''t be typing any sample code but
I''ll get you started on what I would attempt as the solution. Others
my approach this differently so don''t be surprised to see the right
answer in here with mine, hehehe ...
Read the character input one character at a time and put it in a char
array (computationally cheap) or append it to a string
(computationally expensive). As each char is read in output an ''*'' to
the console.
Ken Wilson
Seeking viable employment in Victoria, BC
这篇关于如何使控制台隐藏键入的密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!