//使用MD5类计算数据的哈希值
using System;
using System.Security.Cryptography;
using System.Text;
namespace Examples.System.Net
{
public class MD5CryptoServiceProviderDemo
{
public static void Main(string[] args)
{
string password = "Pa$$w0rd";
MD5CryptoServiceProvider provider = new MD5CryptoServiceProvider();
byte[] hashedPassword = provider.ComputeHash(Encoding.Default.GetBytes(password));
StringBuilder displayString = new StringBuilder();
for (int counter = 0; counter < hashedPassword.Length; counter++)
{
displayString.Append(hashedPassword[counter].ToString("x2"));
}
Console.WriteLine(displayString);
Console.ReadLine();
}
}
}
本文转自 ☆★ 包罗万象网 ★☆ - http://www.baoluowanxiang.com 转载请注明出处,侵权必究!
原文链接:http://www.baoluowanxiang.com/a/program/csharp/2010/1014/1800.html