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


C# SecureString.IsReadOnly方法代码示例

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


在下文中一共展示了SecureString.IsReadOnly方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: SqlCredential

        //
        // PUBLIC CONSTRUCTOR
        //

        // SqlCredential
        //  userId: userId
        //  password: password
        //
        public SqlCredential(string userId, SecureString password)
        {
            if (userId == null)
            {
                throw ADP.ArgumentNull("userId");
            }

            if (userId.Length > TdsEnums.MAXLEN_USERNAME)
            {
                throw ADP.InvalidArgumentLength("userId", TdsEnums.MAXLEN_USERNAME);
            }

            if (password == null)
            {
                throw ADP.ArgumentNull("password");
            }

            if (password.Length > TdsEnums.MAXLEN_PASSWORD)
            {
                throw ADP.InvalidArgumentLength("password", TdsEnums.MAXLEN_PASSWORD);
            }

            if (!password.IsReadOnly())
            {
                throw ADP.MustBeReadOnly("password");
            }

            _userId = userId;
            _password = password;
        }
开发者ID:uQr,项目名称:referencesource,代码行数:38,代码来源:SqlCredential.cs

示例3: Set

		public void Set(string host, int port, string userName, SecureString password)
		{
			this.Host = host;
			this.Port = port;
			this.UserName = userName;

			if (this.Password != null) this.Password.Dispose();
			if (!password.IsReadOnly()) password.MakeReadOnly();
			this.Password = password;
		}
开发者ID:Grabacr07,项目名称:Mukyutter.Old,代码行数:10,代码来源:ProxyService.cs

示例4: GetSecureStringValue

 public static string GetSecureStringValue(SecureString value)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     if (!value.IsReadOnly())
     {
         throw new ArgumentException("SecureString must be read only.", "value");
     }
     IntPtr ustr = IntPtr.Zero;
     try
     {
         ustr = Marshal.SecureStringToBSTR(value);
         return Marshal.PtrToStringBSTR(ustr);
     }
     finally
     {
         Marshal.FreeBSTR(ustr);
     }
 }
开发者ID:resumere,项目名称:TonkaBean,代码行数:21,代码来源:SecureUtils.cs

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

示例6: WritePassword

        // internal AND protected
        internal void WritePassword(SecureString password)
        {
            if (_process == null)
                return;

            if (!password.IsReadOnly())
                throw new GpgApiException("The SecureString \"password\" must be readonly");

            using (SecureStringToCharArrayMarshaler m = new SecureStringToCharArrayMarshaler(password))
            {
                _process.StandardInput.Write(m.Value);
                _process.StandardInput.WriteLine();
            }
        }
开发者ID:NotYours180,项目名称:SharpGPG,代码行数:15,代码来源:GpgInterface.cs


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