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

ToArray() public method

public ToArray ( ) : byte[]
return byte[]
		public override byte[] ToArray () 
		{
			return base.ToArray ();
		}

Usage Example

コード例 #1
0
ファイル: CryptoStreamTest.cs プロジェクト: runefs/Marvin
		public void DecryptPartial_TransformFinalBlock_2Pass () 
		{
			byte[] key = {0, 1, 2, 3, 4, 5, 6, 7};
			byte[] iv = {0, 1, 2, 3, 4, 5, 6, 7};
			DES des = DES.Create ();

			byte[] data = Encoding.Unicode.GetBytes ("ximian");	// 12 bytes, 1.5 DES block size
			DebugStream encrypted = new DebugStream ();
			cs = new CryptoStream (encrypted, des.CreateEncryptor (key, iv), CryptoStreamMode.Write);
			cs.Write (data, 0, data.Length);
			cs.Close ();

			data = encrypted.ToArray ();
			DebugStream decrypted = new DebugStream (data);
			cs = new CryptoStream (decrypted, des.CreateDecryptor (key, iv), CryptoStreamMode.Read);
			int len = cs.Read (data, 0, 6);
			Assert.AreEqual (6, len, "Length (1st pass)");
			Assert.AreEqual ("xim", Encoding.Unicode.GetString (data, 0, len), "Partial DES Roundtrip");
			len += cs.Read (data, 6, 8);
			Assert.AreEqual (12, len, "Length (1st+2nd)");
			Assert.AreEqual ("ximian", Encoding.Unicode.GetString (data, 0, len), "Full DES Roundtrip");
			cs.Close ();
		}
All Usage Examples Of MonoTests.System.Security.Cryptography.DebugStream::ToArray