//用MD5算法给数据库中的数据加密
using System;
namespace ShoppingWeb
{
/// <summary>
/// Jiami 的摘要说明。
/// </summary>
public class Jiami
{
public string MD5(string str,int code)
{
if(code==16)
{
return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str,"MD5").ToLower().Substring(8,16) ;
}
if(code==32)
{
return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str,"MD5").ToLower();
}
return "00000000000000000000000000000000";
}
}
}
本文介绍了一个使用MD5算法对数据库中的数据进行加密的方法。通过C#实现,提供了两种不同的输出形式:16位和32位的MD5哈希值。此方法利用了System.Web.Security.FormsAuthentication类的HashPasswordForStoringInConfigFile方法来生成加密字符串。
638

被折叠的 条评论
为什么被折叠?



