精华区 [关闭][返回]

当前位置:月光软件>>讨论区精华>>〖软件开发〗>>● ASP>>★ASP的延伸★>>C# (C Sharp)>>C# 中的MD5 Hash

主题:C# 中的MD5 Hash
发信人: dongbao()
整理人: dongbao(2000-11-10 16:49:50), 站内信件
 using System; using System.Security.Cryptography; class Hash {  publi
c static void Main()  {   string s = "Hello World!";   // convert stri
ng to byte array   // discard upper byte since is usually 0 in Eng.   
int i;   int l;   char[] c = s.ToCharArray();   l = c.GetLength(0);   
byte[] b = new byte[l];   for (i=0; i<l; i++) b[i] = (byte)c[i]; // tr
uncate char value // perform hash operation MD5_CSP md5 = new MD5_
CSP(); md5.Write(b); md5.CloseStream(); // print byte array in a
legible manner byte[] h = md5.Hash; for (i=0; i<h.Length; i++)
{ Console.Write("{0} ", h[i]); if ( (i+9)%8 == 0 ) Console.Write
Line(); } if (i%8 != 0) Console.WriteLine(); } }

--
ICQ:43395237 OICQ:126132  
我自豪我用正版,我骄傲我用盗版!!! 

※ 来源:.月光程序代码网 http://www.moon-soft.com.[FROM: 202.108.7.193]

[关闭][返回]






转载请注明:转载自 月光程序代码网 [ http://www.moon-soft.com ]