隐藏密码文字

Laz*_*usG 6 c# password-protection winforms

我有一个使用UseSystemPasswordChar的文本框,因此它不会显示用户输入的密码.问题是密码仍然可以被类似Spy ++的东西读取.我正在寻找一种方法来隐藏它,就像在Services.msc>登录选项卡中的密码字段中一样.

Lik*_*urg 1

所以尝试这样的事情

        private string realpass = "";
        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (Char) Keys.Back)
                realpass += realpass.Substring(0, realpass.Length - 2);
            realpass += e.KeyChar.ToString();
            textBox1.Text = "";
            for (int i = 0; i < realpass.Length; i++)
                textBox1.Text += "*";
        }
Run Code Online (Sandbox Code Playgroud)