本文整理汇总了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);
}
}
示例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();
}
示例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);
}
}
示例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
}
示例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);
}
示例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);
}
}
示例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");
}
示例8: InsertAt_BiggerThanLength
public void InsertAt_BiggerThanLength ()
{
SecureString ss = new SecureString ();
ss.InsertAt (1, 'a');
}
示例9: InsertAt_Negative
public void InsertAt_Negative ()
{
SecureString ss = new SecureString ();
ss.InsertAt (-1, 'a');
}