在.net 应用MD5加密
//加密处理用户密码
public static string SMD5(string cleanString)
{
return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(cleanString,"MD5").ToLower().Substring(8,16);
}
---------------------------------------------------------------------------------------------------------------------
/// <summary>
/// MD5加密
/// </summary>
/// <param name="InputString">要加密的字串</param>
/// <returns>密文</returns>
public static string Md5hash_String(string InputString)
{
InputString=System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(InputString,"MD5");
return InputString;
}
---------------------------------------------------------------------------------------------------------------------
md5或者其他hash都可以满足你的需求,这种条件下不需要可逆。除了使用HashPasswordForStoringInConfigFile方法外可以用System.Security.Cryptography下的类和方法。
MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider();
byte[] hashedDataBytes = md5Hasher.ComputeHash(System.Text.ASCIIEncoding.GetBytes(strPlainText))