Cryptography 使用md5进行加密。
1,运行结果如图:
代码如下:
View Code
1 MD5 md5 = MD5.Create();
2 Byte[] by = md5.ComputeHash(Encoding.Default.GetBytes("123456"));
3 StringBuilder sb = new StringBuilder();
4 foreach (var b in by)
5 {
6 Console.WriteLine(b.ToString("X3"));
7 sb.Append(b.ToString("X2"));
8 }
9 Console.WriteLine(sb);
10 Console.WriteLine(string.Format("{0:D3}", 1));
11 Console.ReadLine();
2 Byte[] by = md5.ComputeHash(Encoding.Default.GetBytes("123456"));
3 StringBuilder sb = new StringBuilder();
4 foreach (var b in by)
5 {
6 Console.WriteLine(b.ToString("X3"));
7 sb.Append(b.ToString("X2"));
8 }
9 Console.WriteLine(sb);
10 Console.WriteLine(string.Format("{0:D3}", 1));
11 Console.ReadLine();
参考:http://msdn.microsoft.com/zh-cn/library/system.security.cryptography.md5.aspx