本文整理汇总了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");
}