// 这个加密类是用了.net的System.Web.Security类的,因为是标准的,md5跟SHA码,这里有个问题,java输出不一定是16或32位数.
using System;
using System.Web.Security;
namespace common
{
/// <summary>
/// common 的摘要说明。
/// </summary>
public class common
{
public common()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
}
#region 公用加密类
public class EncryptPwd
{
public string md5(string str,int code) // md5加密函数
{
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");
}
return "00000000000000000000000000000000";
}
public string sha1(string str) // SHA加密函数
{
return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str ,"SHA1");
}
}
#endregion
}