本文整理匯總了C#中MonoTests.System.Security.Cryptography.DebugStream.WriteByte方法的典型用法代碼示例。如果您正苦於以下問題:C# DebugStream.WriteByte方法的具體用法?C# DebugStream.WriteByte怎麽用?C# DebugStream.WriteByte使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MonoTests.System.Security.Cryptography.DebugStream
的用法示例。
在下文中一共展示了DebugStream.WriteByte方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: 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");
}