本文整理汇总了C#中MD5.Final方法的典型用法代码示例。如果您正苦于以下问题:C# MD5.Final方法的具体用法?C# MD5.Final怎么用?C# MD5.Final使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MD5
的用法示例。
在下文中一共展示了MD5.Final方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MDTimeTrial
// Measures the time to digest TEST_BLOCK_COUNT TEST_BLOCK_LEN-byte blocks.
private static void MDTimeTrial ()
{
Console.WriteLine ("MD5 time trial. Digesting {0} {1}-byte blocks ...", TEST_BLOCK_LEN, TEST_BLOCK_COUNT);
/* Initialize block */
byte[] block = new byte[TEST_BLOCK_LEN];
for (int i = 0; i < TEST_BLOCK_LEN; i++)
block[i] = (byte) (i & 0xff);
/* Start timer */
DateTime startTime = DateTime.Now;
/* Digest blocks */
MD5 md5 = new MD5 ();
for (int i = 0; i < TEST_BLOCK_COUNT; i++)
md5.Update (block, TEST_BLOCK_LEN);
byte[] digest = md5.Final ();
/* Stop timer */
DateTime endTime = DateTime.Now;
TimeSpan time = endTime - startTime;
Console.WriteLine ("done");
Console.Write ("Digest = ");
MDPrint (digest);
Console.WriteLine ();
Console.WriteLine ("Time = {0} seconds\n", time.TotalSeconds);
Console.WriteLine ("Speed = {0} bytes/second", (long) TEST_BLOCK_LEN * (long) TEST_BLOCK_COUNT / time.TotalSeconds);
}
示例2: MDString
// Digests a string and prints the result.
private static void MDString (string s)
{
System.Text.Encoding encoding = System.Text.Encoding.GetEncoding ("iso-8859-1");
if (encoding == null)
throw new SystemException ("Cannot get iso-8859-1 encoding.");
byte[] bytes = encoding.GetBytes (s);
MD5 md5 = new MD5 ();
md5.Update (bytes);
byte[] digest = md5.Final ();
Console.Write ("MD5 (\"{0}\") = ", s);
MDPrint (digest);
Console.WriteLine ();
}