using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
/// <summary>
/// 使用MD5算法加密(不可逆,无法解密)
/// 把此方法加入CS页面然后直接调用就行了
/// </summary>
/// <param name="password">明文</param>
/// <returns>密文</returns>
public static string EncryptionMD5(string password)
{
System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
byte[] bytes = new byte[16];
System.Text.ASCIIEncoding asc = new System.Text.ASCIIEncoding();
bytes = md5.ComputeHash(asc.GetBytes(password));
return Convert.ToBase64String(bytes);
}
/// <summary>
/// 使用SHA1算法求加密(不可逆,无法解密)
/// </summary>
/// <param name="text">明文</param>
/// <returns>密文</returns>
public static string EncryptionSHA1(string text)
{
return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(text,"SHA1");
}
加密
最新推荐文章于 2024-10-02 22:45:05 发布