当前位置: 首页>>代码示例>>C#>>正文


C# SecureString.ToString方法代码示例

本文整理汇总了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();

        }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:24,代码来源:ApplicationWebService.cs

示例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);
			}
		}
开发者ID:Profit0004,项目名称:mono,代码行数:23,代码来源:SecureStringTest.cs

示例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;
        }
开发者ID:mkramers,项目名称:Projects,代码行数:77,代码来源:OpenVPN.cs

示例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;
 }
开发者ID:goranobradovic,项目名称:niccom.net,代码行数:6,代码来源:User.cs


注:本文中的System.Security.SecureString.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。