MD5加密小记
话不多说,上代码
密码加密的具体方法
public string Encrypt(string username, string password)
{
//首次加密
MD5 md5 = MD5.Create();
byte[] bs = Encoding.UTF8.GetBytes(password + username);
byte[] hs = md5.ComputeHash(bs);
StringBuilder sb = new StringBuilder();
foreach (byte b in hs)
{
sb.Append(b.ToString("x2"));
}
//再次加密
byte[] nbs = Encoding.UTF8.GetBytes(sb.ToString() + username);
byte[] nhs = md5.ComputeHash(nbs);
StringBuilder nsb = new StringBuilder();
foreach (byte nb in nhs)
{
nsb.Append(nb.ToString("x2"));
}
return nsb.ToString();
}
完结,撒花