c# - wpf 密码框到 C# 中的 SecureString

标签 c# wpf

我正在尝试将 wpf 密码框中的数据转换为安全字符串。这是怎么做到的? 到目前为止我所拥有的:

 SecureString pass = new SecureString();
        pass.AppendChar(pbox1.Password);

这当然行不通,那么我如何在不创建常规字符串的情况下获取密码数据呢?

最佳答案

Per MSDN :

When you get the Password property value, you expose the password as plain text in memory. To avoid this potential security risk, use the SecurePassword property to get the password as a SecureString.

您应该避免使用 Password 属性,除非您绝对需要该字符串的纯文本版本。在这种情况下,直接检索 SecureString。

关于c# - wpf 密码框到 C# 中的 SecureString,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2978348/

相关文章:

c# - 如何给下载器添加停止按钮

c# - 在C#中将类作为参数传递,然后想要访问类的属性

c# - 绑定(bind)到 WPF 中的扩展方法

wpf - 在 XAML 中的 ListView 内拉伸(stretch)网格

c# - 如何测试使用 BackgroundWorker 加载的 ViewModel?

c# - 在 WP8 中从 Web URL 加载图像

c# - 调试因拖放而崩溃的控制台应用程序

c# - 如何在 C# 中选择一个值 true 或 false?

c# - WPF ComboBox 在不应该更改的时候更改

c# - 在 WPF Windows 之间发送数据