反序列化在C#中保存为文本的SecureString

时间:2016-12-01 22:49:01

标签: c# powershell securestring

PowerShell可以将值安全地存储在文件中:

PS > Read-Host 'Enter password' -AsSecureString | ConvertFrom-SecureString | Out-File ~\Desktop\SerializedSecurePassword.txt

如何将文本中存储的值反序列化为C#应用程序中的System.Security.SecureString

string path = @"C:\\Users\\<user>\\Desktop\\SerializedSecurePassword.txt";
string contents = File.ReadAllText(path);

System.Security.SecureString SecurePassword = ?;

0 个答案:

没有答案