Deserialize a SecureString saved as text in C#
<p>PowerShell can store a value securely in a file:</p>

<pre><code>PS &gt; Read-Host 'Enter password' -AsSecureString | ConvertFrom-SecureString | Out-File ~\Desktop\SerializedSecurePassword.txt
</code></pre>

<p>How does one deserialize the value stored in the text into a <code>System.Security.SecureString</code> in a C# application?</p>

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

System.Security.SecureString SecurePassword = ?;
</code></pre>