当你需要解密出里面的内容,这时就需要最初的密码:

$passphrase = read-host 'enter the secret pass phrase'
 
$path = "$env:temp\secret.txt"
 
$key = [byte[]]($passphrase.padright(24).substring(0,24).tochararray())
 
try
{
 $decryptedtextsecurestring = get-content -path $path -raw |
 convertto-securestring -key $key -erroraction stop
 
 $cred = new-object -typename system.management.automation.pscredential('dummy', $decryptedtextsecurestring)
 $decryptedtext = $cred.getnetworkcredential().password
}
catch
{
 $decryptedtext = '(wrong key)'
}
"the decrypted secret text: $decryptedtext"

上一篇: C++存储方案和动态分配

下一篇: Drools规则引擎-Drools入门案例

推荐阅读