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


C# SecureString.InsertAt方法代码示例

本文整理汇总了C#中System.Security.SecureString.InsertAt方法的典型用法代码示例。如果您正苦于以下问题:C# SecureString.InsertAt方法的具体用法?C# SecureString.InsertAt怎么用?C# SecureString.InsertAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Security.SecureString的用法示例。


在下文中一共展示了SecureString.InsertAt方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UnsafeConstructor

		public unsafe void UnsafeConstructor ()
		{
			try {
				SecureString ss = null;
				char[] data = new char[] { 'a', 'b', 'c' };
				fixed (char* p = &data[0]) {
					ss = new SecureString (p, data.Length);
				}
				Assert.IsFalse (ss.IsReadOnly (), "IsReadOnly");
				Assert.AreEqual (3, ss.Length, "3");
				ss.AppendChar ('a');
				Assert.AreEqual (4, ss.Length, "4");
				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");
				ss.RemoveAt (0);
				Assert.AreEqual (0, ss.Length, "0c");
				ss.Dispose ();
			}
			catch (NotSupportedException) {
				Assert.Ignore (NotSupported);
			}
		}
开发者ID:Profit0004,项目名称:mono,代码行数:26,代码来源:SecureStringTest.cs

示例2: HBaseWriter

 public HBaseWriter()
 {
     //Get the Hadoop Cluster info and create connection
     this.ClusterName = ConfigurationManager.AppSettings["ClusterName"];
     this.HadoopUserName = ConfigurationManager.AppSettings["HadoopUserName"];
     string HadoopUserPassword = ConfigurationManager.AppSettings["HadoopUserPassword"];
     this.HBaseTableName = ConfigurationManager.AppSettings["HBaseTableName"];
     SecureString pw = new SecureString();
     for(int i = 0; i < HadoopUserPassword.Length; i++){
         pw.InsertAt(i, HadoopUserPassword[i]);
     }
     Uri clusterUri = new Uri(this.ClusterName);
     ClusterCredentials creds = new ClusterCredentials(clusterUri, this.HadoopUserName, pw);
     this.client = new HBaseClient(creds);
     //create table and enable the hbase writer
     if (!client.ListTables().name.Contains(this.HBaseTableName))
     {
         // Create the table
         var tableSchema = new TableSchema();
         tableSchema.name = this.HBaseTableName;
         tableSchema.columns.Add(new ColumnSchema { name = "d" });
         client.CreateTable(tableSchema);
         Console.WriteLine("Table \"{0}\" created.", this.HBaseTableName);
     }
     WriterThread = new Thread(new ThreadStart(WriterThreadFunction));
     WriterThread.Start();
 }
开发者ID:anytimecnc,项目名称:ProjectTeddy,代码行数:27,代码来源:HBaseWriter.cs

示例3: ToUtf8

        public static byte[] ToUtf8(this string text)
        {
            //Debug.Assert(sizeof(char) == 2);
             SecureString m_secString = new SecureString();
             for (int index = 0; index < text.Length; index++)
             {
            m_secString.InsertAt(index, text[index]);
             }

             if (m_secString != null) {
            char[] vChars = new char[m_secString.Length];
            IntPtr p = Marshal.SecureStringToGlobalAllocUnicode (m_secString);
            for (int i = 0; i < m_secString.Length; ++i)
               vChars [i] = (char)Marshal.ReadInt16 (p, i * 2);
            Marshal.ZeroFreeGlobalAllocUnicode (p);

            byte[] pb = StrUtil.Utf8.GetBytes (vChars);
            Array.Clear (vChars, 0, vChars.Length);

            return pb;
             }
             else {
            return StrUtil.Utf8.GetBytes (string.Empty);
             }
        }
开发者ID:enecciari,项目名称:mackeepass,代码行数:25,代码来源:StringExtensions.cs

示例4: SecureEdit

 //static SecureEdit()
 //{
 //   // On Windows 98 / ME, an ANSI character must be used as
 //   // password char!
 //   if(Environment.OSVersion.Platform == PlatformID.Win32Windows)
 //      m_chPasswordChar = '\u00D7';
 //}
 /// <summary>
 /// Construct a new <c>SecureEdit</c> object. You must call the
 /// <c>Attach</c> member function to associate the secure edit control
 /// with a text box.
 /// </summary>
 public SecureEdit(string masterKey)
 {
     try
      {
     m_secString = new SecureString();
     for (int index = 0; index < masterKey.Length; index++)
     {
        m_secString.InsertAt(index, masterKey[index]);
     }
      }
      catch (NotSupportedException)
      {
      } // Windows 98 / ME
 }
开发者ID:enecciari,项目名称:mackeepass,代码行数:26,代码来源:SecureEdit.cs

示例5: HBaseReader

 public HBaseReader()
 {
     //Get the Hadoop Cluster info and create connection
     this.ClusterName = ConfigurationManager.AppSettings["ClusterName"];
     this.HadoopUserName = ConfigurationManager.AppSettings["HadoopUserName"];
     string HadoopUserPassword = ConfigurationManager.AppSettings["HadoopUserPassword"];
     SecureString pw = new SecureString();
     for (int i = 0; i < HadoopUserPassword.Length; i++)
     {
         pw.InsertAt(i, HadoopUserPassword[i]);
     }
     Uri clusterUri = new Uri(this.ClusterName);
     ClusterCredentials creds = new ClusterCredentials(clusterUri, this.HadoopUserName, pw);
     this.client = new HBaseClient(creds);
 }
开发者ID:anytimecnc,项目名称:ProjectTeddy,代码行数:15,代码来源:HBaseReader.cs

示例6: 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

示例7: InsertAt_UsedLikeAppendChar

		public void InsertAt_UsedLikeAppendChar () // #350820
		{
			SecureString ss = new SecureString ();
			ss.AppendChar ('T');
			Assert.AreEqual (1, ss.Length, "AppendChar");
			ss.InsertAt (1, 'e');
			Assert.AreEqual (2, ss.Length, "InsertAt");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:8,代码来源:SecureStringTest.cs

示例8: InsertAt_BiggerThanLength

		public void InsertAt_BiggerThanLength ()
		{
			SecureString ss = new SecureString ();
			ss.InsertAt (1, 'a');
		}
开发者ID:Profit0004,项目名称:mono,代码行数:5,代码来源:SecureStringTest.cs

示例9: InsertAt_Negative

		public void InsertAt_Negative ()
		{
			SecureString ss = new SecureString ();
			ss.InsertAt (-1, 'a');
		}
开发者ID:Profit0004,项目名称:mono,代码行数:5,代码来源:SecureStringTest.cs


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