PowerShell: 隐藏明文密码
来源:互联网 发布:牛彩纽约彩票源码 编辑:程序博客网 时间:2024/05/02 22:13
本文描述如何加密 PowerShell 中的敏感信息,从而避免敏感信息(诸如密码)在代码中被显式的展现出来。这里我们使用 ConvertFrom-SecureString 命令来完成加密操作,需要注意的是,如果我们没有指定Key,那么,将采用基于 Windows 内置的 DPAPI 进行数据的加密。这种情况下,原文的加密和解密必须在同一台机器上,且基于同一个User去进行。
ConvertFrom-SecureString [-SecureString] <SecureString> [[-SecureKey] <SecureString> ] [ <CommonParameters>]
你可以从这里了解该命令的更多信息。
* If no key is specified, the Windows Data Protection API (DPAPI) is used to encrypt the standard string representation.
Your secret was automatically encrypted by the built-in Windows data protection API (DPAPI), using your identity and your machine as encryption key. So only you (or any process that runs on your behalf) can decipher the secret again, and only on the machine where it was encrypted.
加密方式:
[ps]
write-host "Please enter your plain text. (Run this script as Administrator)"
$plainText = Read-Host | ConvertTo-SecureString -AsPlainText -force
$encryptedText = $plainText | ConvertFrom-SecureString
write-host $encryptedText
[/ps]
解密方式:
[ps]
$password = $encryptedText | ConvertTo-SecureString
$cred = New-Object -TypeName System.Management.Automation.PSCredential("JustGiveAName", $password)
$cred.GetNetworkCredential().Password
[/ps]
查看原文:http://nap7.com/me/powershell-hide-plain-password/
- PowerShell: 隐藏明文密码
- Android-密码的明文显示与隐藏
- 明文密码?
- 明文密码
- EditText设置密码显示明文及隐藏切换
- EditText动态管理密码显示与隐藏,明文与星号
- 可怕的明文密码
- 明文显示密码
- 明文显示密码
- Chrome明文存储密码
- 11.明文密码
- 已知明文破解密码
- 明文存放密码动机分析
- 密码竟然是明文存储?
- 利用mimikatz_trunk获取密码明文
- wordpress中保存明文密码
- EditText 明文和密码切换
- MySQL消除明文密码提醒
- Oracle 11g安装到85%的时候就停止不动了
- PostGreSQL数据库检查(2)
- Visual Studio调用MATLAB的配置 (转)
- Qt--- QListWidget的学习使用
- 为什么你要拒绝我 ——苹果AppStore被拒理由大全
- PowerShell: 隐藏明文密码
- 关于安卓使用weight属性的一些见解
- Memo: 关于 Windows 10 使用的几个小提示
- 标准模板库(八):STL算法函数介绍
- 使用axis2将wsdl文件生成本地类的方法
- 有关MODIS数据下载和地面观测气候数据集的说明——好资源与参考
- PowerShell: 远程调用
- delphi正则表达式学习笔记(三)
- C#: 字符串连接 (+=) 与 StringBuilder 效率分析