鸟语天空
MD5加密
post by:追风剑情 2015-12-3 15:10

需导入 using System.Security.Cryptography;

public static class MD5Crypto
{
	//MD5加密(生成32位字符码)
	public static string Encrypt(string input)
	{
		//注意: 编码不同,生成的MD5值也不同
		byte[] buffer = Encoding.UTF8.GetBytes(input);
		MD5 md5 = new MD5CryptoServiceProvider();
		byte[] res = md5.ComputeHash(buffer);
		return BitConverter.ToString(res).Replace("-", "");
	}

	//密码混淆字符串
	public const string PASSWORD_PREFIX = "QwErT#2020&$kLjKNM986sljk@";
	public const string PASSWORD_POSTFIX = "Iklsn%$#@LIl.rXVPo^#123@";
	public static string EncryptPassword(string password)
	{
		string mix_password = string.Format("{0}{1}{2}", PASSWORD_PREFIX, password, PASSWORD_POSTFIX);
		return Encrypt(mix_password);
	}
}

评论:
发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容