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


C# DebugStream.Close方法代码示例

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


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

示例1: NonMultipleOfBlockSize_Decrypt

		private byte[] NonMultipleOfBlockSize_Decrypt (ICryptoTransform ct, byte[] data) 
		{
			DebugStream stream = new DebugStream (data);
			CryptoStream CryptStream = new CryptoStream (stream, ct, CryptoStreamMode.Read);

			int len = 0;
			long myLength = 0;
			byte[] Buffer = new Byte [1024];

			DebugStream fout = new DebugStream ();
			// each returned block must be 1023 bytes long 
			// even if this isn't a multiple of the block size
			while ((len = CryptStream.Read (Buffer, 0, 1023)) != 0) {
				fout.Write (Buffer, 0, len);
				fout.Flush ();
				myLength = myLength + len;
			}

			byte[] result = fout.ToArray ();
			CryptStream.Close ();
			stream.Close ();
			return result;
		}
开发者ID:runefs,项目名称:Marvin,代码行数:23,代码来源:CryptoStreamTest.cs

示例2: WriteByteReadByte

		public void WriteByteReadByte () 
		{
			DebugStream original = new DebugStream (Encoding.Unicode.GetBytes ("ximian"));

			DebugStream encrypted = new DebugStream ();
			byte[] key = {0, 1, 2, 3, 4, 5, 6, 7};
			byte[] iv = {0, 1, 2, 3, 4, 5, 6, 7};
			DES des = DES.Create ();
			cs = new CryptoStream (encrypted, des.CreateEncryptor (key, iv), CryptoStreamMode.Write);

			int data;
			while ((data = original.ReadByte ()) != -1)
				cs.WriteByte((byte) data);
			cs.Close ();

			byte[] result = encrypted.ToArray ();
			Assert.AreEqual ("18-EA-93-3F-20-86-D2-AA-78-02-D7-6F-E4-47-17-9C", BitConverter.ToString (result), "Encrypted");

			encrypted = new DebugStream (result);
			DebugStream decrypted = new DebugStream ();
			cs = new CryptoStream (encrypted, des.CreateDecryptor (key, iv), CryptoStreamMode.Read);

			while ((data = cs.ReadByte ()) != -1)
				decrypted.WriteByte((byte) data);
			cs.Close ();
			decrypted.Close ();

			Assert.AreEqual ("ximian", Encoding.Unicode.GetString (decrypted.ToArray ()), "W/R Byte Roundtrip");
		}
开发者ID:runefs,项目名称:Marvin,代码行数:29,代码来源:CryptoStreamTest.cs

示例3: NonMultipleOfBlockSize_Encrypt

		// Adapted from Subba Rao Thirumoorthy email on mono-devel-list (december 2003)
		private byte[] NonMultipleOfBlockSize_Encrypt (ICryptoTransform ct, byte[] data)
		{
			DebugStream stream = new DebugStream ();
			CryptoStream CryptStream = new CryptoStream (stream, ct, CryptoStreamMode.Write);

			int len = 0;
			long myLength = 0;
			byte[] Buffer = new byte [1024];
			
			DebugStream fout = new DebugStream (data);
			while (myLength < data.Length) {
				len = fout.Read (Buffer, 0, 1023);
				if (len == 0)
					break;
				CryptStream.Write (Buffer, 0, len);
				CryptStream.Flush ();
				myLength = myLength + len;
			}
			CryptStream.FlushFinalBlock ();
			// we must ensure that the result is correct
			Assert.AreEqual (64, len, "Length(final)");
			byte[] result = stream.ToArray ();
			string end = BitConverter.ToString (result, 65520, 16);
			Assert.AreEqual ("04-70-19-1D-28-C5-BD-9A-23-C6-60-E2-28-96-38-65", end, "End part");

			CryptStream.Close();
			stream.Close();
			return result;
		}
开发者ID:runefs,项目名称:Marvin,代码行数:30,代码来源:CryptoStreamTest.cs


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