[C#] 纯文本查看 复制代码 protected void Page_Load(object sender, EventArgs e)
{
Response.Write(getsha1(System.Text.Encoding.UTF8.GetBytes("123456")));
}
/// <summary>
/// 根据Byte生成SHA1
/// </summary>
/// <param name="bytes"></param>
/// <returns></returns>
public string getsha1(byte[] bytes)
{
try
{
SHA1 sha1 = SHA1.Create();
byte[] hashBytes = sha1.ComputeHash(bytes);
string str = string.Empty;
foreach (var item in hashBytes)
{
str += string.Format("{0:X}", item);
}
return str;
}
catch { }
return string.Empty;
}
|