将SecureString放入PasswordBox [英] Put SecureString into PasswordBox

查看:101
本文介绍了将SecureString放入PasswordBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个现有的我想放入

I have an existing SecureString that I would like to put into a PasswordBox without revealing the .Password. Can this be done? For example:

tbPassword.SecurePassword = DecryptString(Properties.Settings.Default.proxyPassword);

在这种情况下,DecryptString生成SecureString.但是, SecurePassword 是只读属性,因此我无法为其分配值.

In this case DecryptString produces a SecureString. However, SecurePassword is a read-only property so I can't assign a value to it.

推荐答案

您不能.

但是,您可以做的是在其位置放置占位符文本(甚至可以是"placeholder",我们仅使用它在框中显示一些点).

However, what you can do is put placeholder text in it's place (it can even be "placeholder", we are only using it to make a few dots to show up in the box).

在放置占位符之后,当您去检索程序中某个位置的当前密码"时,请首先检查PasswordBox的passwordbox.securepassword%28v = vs.110%29.aspx"rel =" noreferrer> SecurePassword 属性.

After you put the placeholder in, when you go to retrieve the "current password" somewhere in your program first check if the PasswordChanged event has fired since you entered the placeholder password. If the event has not fired use the old stored password, if the event has fired use the current password from the SecurePassword property of PasswordBox.

这篇关于将SecureString放入PasswordBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆