本文整理汇总了C#中System.Security.SecureString.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# SecureString.ToString方法的具体用法?C# SecureString.ToString怎么用?C# SecureString.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.SecureString
的用法示例。
在下文中一共展示了SecureString.ToString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WebMethod2
/// <summary>
/// This Method is a javascript callable method.
/// </summary>
/// <param name="e">A parameter from javascript.</param>
/// <param name="y">A callback to javascript.</param>
public void WebMethod2()
{
var x = new SecureString();
x.AppendChar('p');
x.AppendChar('a');
x.AppendChar('s');
x.AppendChar('s');
x.AppendChar('w');
x.AppendChar('o');
x.AppendChar('r');
x.AppendChar('d');
// SecureString seems to be one way PKI. no way to read it?
var xx = x.ToString();
}
示例2: DefaultConstructor
public void DefaultConstructor ()
{
try {
SecureString ss = new SecureString ();
Assert.IsFalse (ss.IsReadOnly (), "IsReadOnly");
Assert.AreEqual (0, ss.Length, "0");
ss.AppendChar ('a');
Assert.AreEqual (1, ss.Length, "1");
ss.Clear ();
Assert.AreEqual (0, ss.Length, "0b");
ss.InsertAt (0, 'b');
Assert.AreEqual (1, ss.Length, "1b");
ss.SetAt (0, 'c');
Assert.AreEqual (1, ss.Length, "1c");
Assert.AreEqual ("System.Security.SecureString", ss.ToString (), "ToString");
ss.RemoveAt (0);
Assert.AreEqual (0, ss.Length, "0c");
ss.Dispose ();
}
catch (NotSupportedException) {
Assert.Ignore (NotSupported);
}
}
示例3: StartOpenVPN
public static bool StartOpenVPN(string _config, string _serviceName, string _userName, SecureString _password)
{
string command = $"openvpn --config {_config} --service {_serviceName} 0";
Process process = null;
ProcessStartInfo processInfo = null;
Debug.WriteLine("Command = " + command);
Debug.WriteLine("");
Console.WriteLine(Divider);
Console.WriteLine("OpenVPN" + Divider);
Console.WriteLine(Divider);
Console.WriteLine("Username: " + _userName);
Console.WriteLine("Password: " + _password.ToString());
Console.WriteLine();
Console.Write("Trying...");
bool success = false;
try
{
processInfo = new ProcessStartInfo("cmd.exe", "/C " + command);
processInfo.UseShellExecute = false;
processInfo.RedirectStandardInput = true;
processInfo.RedirectStandardOutput = true;
process = new Process();
process.StartInfo = processInfo;
process.Start();
process.StandardInput.WriteLine(_userName);
Thread.Sleep(20);
process.StandardInput.WriteLine(_password.ToString());
Thread.Sleep(20);
int ticks = 0;
while (!success && !process.HasExited && ticks < 100)
{
string line = process.StandardOutput.ReadLine();
Debug.WriteLine($">>{line}");
if (line.Contains("Initialization Sequence Completed"))
{
success = true;
}
ticks++;
}
if (success)
{
Console.WriteLine("...Success");
}
else
{
Console.WriteLine("...Failed");
}
Console.WriteLine(Divider);
Console.WriteLine(Divider);
Console.WriteLine(Divider);
}
catch (Exception e)
{
Console.WriteLine("Error Opening : " + e.Message);
Console.WriteLine(e.StackTrace);
}
finally
{
process.Close();
process = null;
}
return success;
}
示例4: Create
public static User Create(string userName, SecureString password)
{
var user = new User(userName, string.Empty, DateTime.Now);
user.PasswordHash = GetPasswordHash(password.ToString(), GetPasswordSalt(user.CreatedOn));
return user;
}