C#我记得带个函数,进行MD5加密的,哪位大哥告诉我怎么用?顺便告诉我怎么给别人加分.万分感谢.Q536823,加Q教我也行..
解决方案 »
- asp.net让我头疼不已,至今没学会
- 高手看看, 一样的错误不一样的原因. 又是调用非托管DLL的问题, PInvoke函数出错, 堆栈不对称.
- 求教:winform下listview虚拟模式逐个加载item的问题
- 写个泛型的小代码,结果发现泛型不能比较,谢谢啦
- 求助(急):在外网,SQL Server 不存在或访问被拒绝的错误
- 为什么,何时(好处)要用抽象类,接口,以及他们使用上不仅仅是语法上的区别?
- 在C#中使用DataGridView 控件 完成网页上的增加 删除 查询 功能 怎么实现啊 ?哪位高手能写个代码给我,我是菜鸟~ 我在线等
- DropDownList1.Items.FindByText 提示:未将对象引用设置到对象的实例
- 急!!!!!!!
- 如何在C#中使用COOLBAR
- 如何删除用户选择的文件夹?如何获取所选文件夹的名称?
- 一个C#的弹出框问题
MD5 md1 = MD5.Create();
string sjiami = BitConverter.ToString(md1.ComputeHash(buffer1));
function TForm_SetWebSuPassword.GetMd5String(strIn: string): string;
var
MyMD5:MD5CryptoServiceProvider;
begin
MyMD5:=MD5CryptoServiceProvider.Create();
result:=BitConverter.ToString(MyMD5.ComputeHash(Encoding.Default.GetBytes(strIn))).Replace('-','').ToLower();
end;
{
string temp = "";
if (str != "")
{
temp = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5");
temp = temp.Substring(0,8).ToLower();
}
return temp;
}
byte[] data = new byte[DATA_SIZE];
// This is one implementation of the abstract class MD5.
MD5 md5 = new MD5CryptoServiceProvider();
byte[] result = md5.ComputeHash(data);
{
//MD5加密字符串
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
byte[] encryptedBytes = md5.ComputeHash(Encoding.Unicode.GetBytes(inputString));
System.Text.StringBuilder sb = new System.Text.StringBuilder();
for (int i = 0; i < encryptedBytes.Length; i++)
{
sb.AppendFormat("{0:x2}", encryptedBytes[i]);
}
return sb.ToString();
}
using System;
using System.Security.Cryptography;
using System.Text;class Example
{ static string getMd5Hash(string input)
{
MD5 md5Hasher = MD5.Create(); byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(input)); StringBuilder sBuilder = new StringBuilder(); for (int i = 0; i < data.Length; i++)
{
sBuilder.Append(data[i].ToString("x2"));
} return sBuilder.ToString();
} static bool verifyMd5Hash(string input, string hash)
{
string hashOfInput = getMd5Hash(input); StringComparer comparer = StringComparer.OrdinalIgnoreCase; if (0 == comparer.Compare(hashOfInput, hash))
{
return true;
}
else
{
return false;
}
}
static void Main()
{
string source = "Hello World!";
string hash = getMd5Hash(source); Console.WriteLine("The MD5 hash of " + source + " is: " + hash + "."); Console.WriteLine("Verifying the hash..."); if (verifyMd5Hash(source, hash))
{
Console.WriteLine("The hashes are the same.");
}
else
{
Console.WriteLine("The hashes are not same.");
}
}
}
label.Text = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(textBox1.Text,"MD5");
http://www.cnblogs.com/heekui/archive/2007/02/14/650290.html
{
return FormsAuthentication.HashPasswordForStoringInConfigFile (pwd, "MD5");
}
public static string MD5(string inputString)
{
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
byte[] encryptedBytes = md5.ComputeHash(Encoding.Unicode.GetBytes(inputString));
System.Text.StringBuilder sb = new System.Text.StringBuilder();
for (int i = 0; i < encryptedBytes.Length; i++)
{
sb.AppendFormat("{0:x2}", encryptedBytes[i]);
}
return sb.ToString();
}