MonoTests.System.Security.Cryptography.DebugStream.Read C# (CSharp) Method

Read() public method

public Read ( [ buffer, int offset, int count ) : int
buffer [
offset int
count int
return int
		public override int Read ([In,Out] byte[] buffer, int offset, int count)
		{
			int len = base.Read (buffer, offset, count);
			return len;
		}

Usage Example

Example #1
0
		// 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;
		}