ToSecureString
Converts a string into a "SecureString"
Source
/// <summary>
/// Converts a string into a "SecureString"
/// </summary>
/// <param name="str">Input String</param>
/// <returns></returns>
public static System.Security.SecureString ToSecureString(this String str)
{
System.Security.SecureString secureString = new System.Security.SecureString();
foreach (Char c in str)
secureString.AppendChar(c);
return secureString;
}
Example
String password = "mypassword";
System.Security.SecureString secure = password.ToSecureString();