英文:
Powershell GUI, How to take password input without exposing
问题
我有一个情况,我正在编写一个PowerShell图形界面。
我需要以安全的方式获取密码输入... 我该如何做?
密码输入需要在窗口中保护。
下面是我的代码:
$Passwd = New-Object system.Windows.Forms.TextBox
$Passwd.multiline = $false
$Passwd.width = 150
$Passwd.height = 20
$Passwd.location = New-Object System.Drawing.Point(169,26)
$Passwd.Font = New-Object System.Drawing.Font('Microsoft Sans Serif',10)
$Passwd.ForeColor = [System.Drawing.ColorTranslator]::FromHtml("#7ed321")
$Passwd.BackColor = [System.Drawing.ColorTranslator]::FromHtml("#000000")
这是代码。
密码输入需要保持安全吗?
英文:
I have a situation I am writing a powershell GUI.
I need to take the password in a secure input.. How can I do it ?
The passwd input need to be secured in the window
below is my code
$Passwd = New-Object system.Windows.Forms.TextBox
$Passwd.multiline = $false
$Passwd.width = 150
$Passwd.height = 20
$Passwd.location = New-Object System.Drawing.Point(169,26)
$Passwd.Font = New-Object System.Drawing.Font('Microsoft Sans Serif',10)
$Passwd.ForeColor = [System.Drawing.ColorTranslator]::FromHtml("#7ed321")
$Passwd.BackColor = [System.Drawing.ColorTranslator]::FromHtml("#000000")
this is the code
the passwd input nee to be secured input ?
答案1
得分: 0
需要将UseSystemPasswordChar
设置为 $true
:
$Passwd.UseSystemPasswordChar = $true
答案2
得分: 0
我尝试了system.Windows.Forms.TextBox,它有效。
英文:
I tried system.Windows.Forms.TextBox, it worked.
$Passwd = New-Object system.Windows.Forms.TextBox
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论