Home All Groups Group Topic Archive Search About

How to convert string to SecureString?

Author
23 Aug 2006 9:24 PM
Bishoy George
I want to pass a string password in System.Diagnostics.Process.Start.

The problem is that the defined password parameter is SecureString not
string while my password is string.

Normal casting evaluates to errors.

Please how to cast string to SecureString?

Many Thanks in Advance.

Bishoy

Author
28 Aug 2006 2:46 PM
Marina Levit [MVP]
I don't know if you can. I think you have to append on character at a time
to the secure string.

Show quoteHide quote
"Bishoy George" <bis***@bishoy.com> wrote in message
news:O33fopvxGHA.2396@TK2MSFTNGP03.phx.gbl...
>I want to pass a string password in System.Diagnostics.Process.Start.
>
> The problem is that the defined password parameter is SecureString not
> string while my password is string.
>
> Normal casting evaluates to errors.
>
> Please how to cast string to SecureString?
>
> Many Thanks in Advance.
>
> Bishoy
>
Author
30 Aug 2006 5:47 PM
Alun Jones
"Marina Levit [MVP]" <someone@nospam.com> wrote in message
news:uR%23pFDryGHA.3440@TK2MSFTNGP06.phx.gbl...
>I don't know if you can. I think you have to append on character at a time
>to the secure string.

My impression is that this is deliberate.  You can create a SecureString
from a Char * array, or you can add characters into the secure string - you
can even manipulate portions of the string to match editing behaviours in a
dialog box or at the console.

If this is deliberate (and I hope it is), it is to prevent users from
putting passwords into a String and then into a SecureString.  The
raison-d'etre of SecureString is to prevent passwords from remaining
unencrypted in memory due to the intermittent nature of garbage collection -
and if you put the password into a String, either on the way into a
SecureString, or on the way out, that String value is subject to the GC's
decision as to when it might be nice to zero out the string and remove it
from memory.

Alun.
~~~~
[MS MVP, Windows - Security]