Re: How to convert string to SecureString?



"Bishoy George" <bishoy@xxxxxxxxxx> wrote in message
news:umHfhovxGHA.4972@xxxxxxxxxxxxxxxxxxxxxxx
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



-------------------------------------

I found a simple way:

char[] passwordChars = passwordPre.ToCharArray();

SecureString password = new SecureString();

foreach (char c in passwordChars)

{

password.AppendChar(c);

}


.



Relevant Pages

  • Re: Best practice SecureString and pswd collection
    ... because ConsoleKeyInfo just keeps one char in it's structure. ... There is never a string exposed. ... SecureString password = new SecureString; ...
    (microsoft.public.dotnet.security)
  • Re: Destroy a string
    ... public static unsafe void OverwriteString{ ... The string is still on the heap, ... That's why the SecureString was invented, it get's allocated in a non swappable fixed ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: System.Diagnostics.Process() hangs
    ... very simple and runs %system% ver, and returns the windows version. ... webservice will need to invoke an exe (which is a server application ... public string CreateTSUser ... SecureString securePass = new SecureString; ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: System.Diagnostics.Process() hangs
    ... you redirected output & input, then did a wait for task exit. ... exit until it writes its output, which you won't read until it exits. ... public string CreateTSUser ... SecureString securePass = new SecureString; ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: SecureString() in framework 1.1
    ... Note that the use of SecureString is not needed and that the same code would ... The SecureString allows to crpt/decrypt the string when needed and the ... Also as a side note it's likely best to always code for the framework you ... 1- how can use securestring whit fw 1.1? ...
    (microsoft.public.dotnet.languages.vb)